1

I have a settings.xml file that I use to set various global variables within my app. I want to be able to create sub xml files that I include in the settings.xml file because depending on the client, I change settings in this file so I want to make it easier on myself.

I know that there is a way to include layout files this way but I can't find any documentation that shows how to do this with plain XML on Android.

Any help would be much appreciated.

rplankenhorn
  • 2,075
  • 2
  • 22
  • 32
  • If I guessed it right, your build process involves several configuration files => several APKs for different clients. If so, you could consider library projects. Most stuff goes to a single library project; the differences live in separate projects, one per client. A few things go with the territory, such as debug quirks, but it's all manageable. – full.stack.ex Jan 03 '13 at 20:40
  • Yes we have this setup but the issue is that we have production servers and development servers that use different keys to access. I occasionally change to production to test and therefore I change the keys. – rplankenhorn Jan 03 '13 at 21:45
  • Can't try this on Android right now. But it worked with regular XML parsers. If the Android environment accepts this, an entity can refer to a file outside the project directory: http://xml.silmaril.ie/includes.html – full.stack.ex Jan 03 '13 at 22:13
  • I actually found this and tried it but it didn't work on Android. I am thinking the only way to actually do this would have the name of the file to be included in the first file and then parse it and read it in code. Kind of a hack but I can't see any other way. – rplankenhorn Jan 04 '13 at 15:55

1 Answers1

-1

I think all you have to do is make an additional file which includes the settings you want.

Ie, I have strings.xml in values

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="main_title">Hello there</string>
</resources>

And I can create additionalstrings.xml in the values folder

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="additional">How are you?</string>
</resources>

I can refer to either R.string.main_title or R.string.additional, without having to say the file it came from.

brismith
  • 696
  • 3
  • 18