Definitely I will go with android resources under values as string. so you name it once and get benefit of the powerful tools from Android studio for customization and localization by Locale, buildtype, and flavors... I just would suggest to set urls in separated file. i.e. urls.xml
<resources>
<string name="url_server1">http://apipas.com/gloabl/server1</string>
<string name="url_server2">http://apipas.com/global/server2</string>
</resources>
For simple project it might not matter.. but when you are dealing wth an enterprise one,or with multiple targets, multiple-language, different server tiers (based on location;EU/Asia... , or on usage:free/paid, or on phase:dev/testing/production) it will be crucial what way you select to manage such as resources.
Let me elaborate that... lets say we have this build.gradle for app:
buildTypes {
debug {
debuggable false
applicationIdSuffix 'debug'
}
qa {
debuggable false
applicationIdSuffix 'qa'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
paid {
applicationId = "com.apipas.android.wellmanagerurlsapp.paid"
}
free {
applicationId = "com.apipas.android.wellmanagerurlsapp.free"
}
}
Also it supports de as german language and Australian locale en-rAU
So we have these customization factors:
- Flavor : paid/free ( it can be something else: CPU arch,regions,... etc)
- BuildType: in addition to Release and Debug I added QA to test app with testing server if available.
- Locales: base,de, & en-rAU
All what you need to do is just to override res in correct location that fulfills what you need to achieve
Lets say I'd to use buildType base to customize URLS :
Or you'd use Flavors:
Be aware not to fall with duplication when use flavor and buildType together to customize res.
Along developing, you dont need to change the name of url.. this is really a good point when you have big project. still you can change content easily for any flavor/buildType/locale
You can also use JSON, XML, or properties as you referred. but none of them will give you what res do.
Good luck,'.