• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to handle multiple property files with Android?

johnrodey

Lurker
I would like to have multiple property files checked in to my project that each define the same properties but for different environments. For instance, a development one and an operational one that each point to a different server.
Ex. myapp.properties.dev
-> server.host=1.2.3.4
-> server.port=8080
myapp.properties.ops
-> server.host=5.6.7.8
-> server.port=8081

I would like to have some way when building my android project to an apk to specify which property file to include and rename it to just myapp.properties.

How can I achieve this?

Is there a more android'esk way of doing this?

Thanks
 
This is something you do with Apache Ant.

You'd have to setup the variables yourself in the build file.*

But then all you would have to do is build from the command line with something like:

Code:
C:> ant release
For testing purposes I would have your app default to the dev properties, unless you want to build with ant for every dev build (would be a hassle I think). Though I dont know enough about Eclipse/Ant - there is probably a way to set it up to integrate.


*There should be a number of Ant tutorials on Google you can find (not specific to Android) but also a number that are specific to Android that relate to building with Proguard (an open-source code obfuscation tool).
 
Thanks alostpacket,

I'm pretty familiar with Ant, but I didn't want to need to build command line to take advantage of this.

I am currently building in Eclipse and would like to find a way to instruct Eclipse to call my ant target if possible. ...or I could alter the Ant build to behave like I want but have a way when running through eclipse to specify which property file you want to run with, such as -Dpropfile=myapp.properties.dev

I have not had luck finding a way via the Run Configuration.

Any ideas?
 
Back
Top Bottom