lets us assume that i am using service or database path in my application,so whenever i change the location path, i don’t want to edit in all the ton times in coding. so is it possible to store the value in some xmlfile or manifest file and read it directly to a variable? or i have to use xml parser? any idea?
Share
You have more than an option:
1- you can create your own file (txt or xml) this is up to you, and when you create your activity or service you can read the file by using:
2-You can add it as String value in your resource folder(eclipse creates res folder for you by default so you can find a file called strings.xml using the following path:
res->values->strings.xml
so in this file you can add your string like :
so when you want to read it from your activity or service, you can say:
or you can use a static interface which has all the constants you use;since you can’t modify the value at run time, but if there is an ability to modify this value at runtime; you need to store either in SharedPreference, or create your own DB and store it.