Not quite the only way, actually. But it does depend on loading the class that defines the fields AFTER you get your hands on the context.
What you can do is to save that context in a static (non-final) field, in a different class. Then, in the class with your fields, you include a static method that computes the necessary values. This will reference the saved context in the class above to do any resource loading. Your static final fields then look like this: public static final HashMap<String,String> MYTABLE = loadHashMap(R.array.mytable_keys, R.array.mytable_values); or public static final HashMap<String,String> MYTABLE = loadHashMap(R.xml.mytable); That's kind of convoluted, however. You have to be careful not to touch the class too early, which may cause you to also warp other parts of your application. You'd have to decide whether that's better or worse than doing code-generation. On Apr 13, 4:13 pm, HippoMan <hippo.mail...@gmail.com> wrote: > Thanks, but your suggestion won't work for me, because I can't > statically access the values of arrays defined as resources. These > arrays can only be retrieved via an already created Context object > through the use of getResources().getStringArray(). > > Recall that I am looking to use these values to instantiate static > final fields. > > The only way to do this is via code generation. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject.