Issue
I'm trying to place some API URLs somewhere so that the app can fetch them when needed. For instance, it needs to fetch the Google Calendar API URLs to retrieve the calendars, events, etc.
Is it a good idea to have them hardcoded and stored in string.xml? Otherwise, what would be a better approach?
Thanks
Solution
According to this thread you can store url in string.xml
I personnaly prefer to create a "contract" file in order to store informations about API. For example
//No need to use "static final" attributes because this is an interface an not a class
public interface APIContract {
String BASE_URL = "";
//...
}
Now you can use it in your code using
APIContract.BASE_URL
Answered By - ThomasThiebaud
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.