I have 10 URL’s in my application, that are currently hard-coded. I want to externalize this and put it in a file so that my application can read it in.
What is the best way of doing this?
private String appURL = "http://..."
private String storeURL = "http://..."
private String someURL = "http://..."
Note: I will never be writing out to this file in my app. I want the developer to be able to open up the file, and change the URL if necessary.
Easiest way to externalize strings in an android application is to use string resources. Create file
uris.xmlatres/valuesfolder:You then can then access the strings by:
getString()is a method ofContextclass. Also keep in mind that you should wait until aContextwill be initialized before starting access its resources. Hence invokegetString()not earlier then atonCreate()method ofActivityorApplication.