2

I have two string that store in string.xml like this

<string name="Domain">http://discovervideo.com/station/index.guid=</string>
<string name="Guid">default</string>

and two EditText t1 , t2 while

t1 = (EditText) findViewById(R.id.server1);
t2 = (EditText) findViewById(R.id.signage1);

I want when user input this two string it update to string.xml where I used them in another activity like

String Domain = getResources().getString(R.string.Domain);
String GUID = getResources().getString(R.string.Guid);

It is possible to do that?

2 Answers2

1

For this, you should probably used SharedPreferences.

SharedPreferences prefs;
prefs = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);

// To save a string...
prefs.edit().putString(KEY_WHATEVER, "Your value").commit();

// To load that string
prefs.getString(KEY_WHATEVER, "A default value");

Then you just need to create the FILE_NAME and KEY_WHATEVER variables (and probably give them better names). They are just used so that SharedPreferences knows what to load.

user184994
  • 17,791
  • 1
  • 46
  • 52
0

That's not possible as far as I know (another SO question about it). Consider using SharedPreferences for that purpose.

Community
  • 1
  • 1
SantiM
  • 192
  • 8
  • Santi, instead of posting an answer (beside that maybe should be a comment) with a dup question, it might be better to flag this question as a duplicate. Thank you. – Blo May 17 '14 at 15:26
  • You're right. Excuse me! – SantiM May 17 '14 at 15:27