Create a dummy preferences.xml file in res/xml/ of the library. The real file from your project will override it.
On Thu, Feb 24, 2011 at 1:52 PM, Bret Foreman <bret.fore...@gmail.com> wrote: > I've created a set of handy xml parsers for the preferences file > (R.xml.preferences) and created a class called PrefrencesHelper. This > worked fine when the class was in the main project. But I want to > share PrefrencesHelper as a library. > > In the non-lib version, I instantiate the parser like this inside each > PrefrencesHelper method: > > XmlResourceParser parser = getResources().getXml(R.xml.preferences); > > So there is always a fresh instance of the pull parser when I want to > parse something out. > > But that's not going to work in a lib where the R class I want is in > the main project. The local library R class won't contain > R.xml.preferences. > > I see two options. Maybe you folks can help me think of a third, > better way: > > 1) Instantiate a fresh parser in the main project whenever I call a > PrefrencesHelper method and include that as one of the arguments. This > is really messy and I want to avoid it at all costs. > > 2) Instantiate the parser once in the main project and pass it to the > PrefrencesHelper constructor. But if I do this, I need to figure out a > way to "rewind" the parser and make it start from the beginning of the > file with each PrefrencesHelper method call. I haven't found any easy > way to do that. > > Any ideas? > > > -- > 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 > -- Xavier Ducrohet Android SDK Tech Lead Google Inc. http://developer.android.com | http://tools.android.com Please do not send me questions directly. Thanks! -- 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