java - Can I access a string resource from string.xml into an activity in Android? -


this question has answer here:

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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -