ahodder
ahodder

Reputation: 11439

A static resource file?

Android uses a static resource file R. This file (at least in eclipse) is automatically updated when ever you add new id's of any sort. How can I create/implement the same feature in a normal java application? Is it as simple as just writing an xml parser and just updating the resource file after the xml is modified?

Upvotes: 1

Views: 312

Answers (2)

lpinto.eu
lpinto.eu

Reputation: 2127

You didn't specified the type or the use of the resources. I don't know android, but I'll try to help; If you just need to access some resource in your application you can use properties or resource, there are some differences see this other question Properties vs Resource Bundle

Upvotes: 0

Joseph Earl
Joseph Earl

Reputation: 23432

In a way, yes. You need to create a custom build script/program which runs at the start of each build (before anything else), scans your resource folder files (and if they are XML files it needs to read in the XML files and parse out the string resources or whatever from those), then write it all to a Java file in some manner (e.g. R.string_name = "string value").

Make sure the XML files aren't actually packaged in your .jar, since all that information will be stored inside your Java resources file now.

For things which aren't XML files you could just store the filename as a string in the Java resources file.

Upvotes: 1

Related Questions