Yeah, that's messy, but it will probably work. One other consideration is what the next version of Android will do about this. It's pretty clear that this is an important missing feature. I expect they'll eventually make a version of getXXX that reads the default value from preferences.xml if there's no key-value pair in the database yet, and throws an exception if no default value is found. From that perspective, it makes more sense to put a wrapper around getXXX and do my own parsing of the default values from preferences.xml. This has the added advantage that addition and removal of new preference keys can happen in the same file where the defaults are defined. And then when the improved version of getXXX comes out, I can just remove the wrapper.
The drawback of this is that I know very little about XML parsers. It looks like I can use DocumentBuilder.parse for this purpose if I can figure out how to open the file. Does this code look right for getting at the raw xml data? AssetManager myAssets = myContext.getAssets(); DisplayMetrics myDM = new DisplayMetrics(); myDM.setToDefaults(); Configuration myConfig = new Configuration(); myConfig.setToDefaults(); Resources myResources = new Resources( myAssets , myDM , myConfig ); prefInputStream = myResources.openRawResource(R.xml.preferences); -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. ATTENTION: Android-Beginners will be permanently disabled on August 9 2010. For more information about this change, please read [http://goo.gl/xkfl] or visit the Group home page. Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en