java - Can I access a string resource from string.xml into an activity in Android? -
this question has answer here:
- android: how string resources using name? 11 answers
i creating android application need use ip of server in many different activities access php files. every time connect new network, manually change ips in activities.
my question is, can declare string resource in values-->strings.xml, , change there, modifications done @ once?
i know can access string resource in xml file using " @string/my_string_var", my_string_var variable name actual string.
can use string resource in of activities, this:
final string ip = @string/final_ip;
it work fine you
(your activity context).this.getresources().getstring(r.string.final_ip);
or simple in activity
getresources().getstring(r.string.final_ip);
Comments
Post a Comment