A
A
Al2017-03-16 18:11:56
Android
Al, 2017-03-16 18:11:56

Where is the best place to store static string resources in android?

Let's say I have some options.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="host">api.site.com</string>
    <string name="port">9001</string>
    <string name="protocol">http</string>
</resources>

And I get the value like this: requestManager.request(getString(R.string.host), ...
Is this a good way, or is there a better practice?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lopatoid, 2017-03-23
@lopatoid

Well, if the hostname, port and protocol do not change depending on the language, screen size, etc., then you can simply store this in a class with constants
public static final String HOST = "api.site.com";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question