Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write data in String.xml Android

I want to write some values from editText of activity in the file string.xml. I will explain with an example:

In the activity I have 2 editText and 1 button to submit the information. Imagine that the editText are for inserting NAME and SURNAME. I have the following code in string.xml

<string name="person_name"></string>
<string name="person_surname"></string>

At the begining, those fields will be empty but after submiting the info, I want to write the values obtained from the editTexts in that file.

Any suggestion?

Thanks in advance

like image 834
Martin Solac Avatar asked Feb 22 '26 13:02

Martin Solac


2 Answers

That's not possible. Strings.xml is only for storing predefined strings. Use SharedPreferences to store this data.

like image 160
Robby Pond Avatar answered Feb 24 '26 04:02

Robby Pond


Although what you want is not possible but can be done through SharedPreferences http://developer.android.com/guide/topics/data/data-storage.html#pref

like image 25
ingsaurabh Avatar answered Feb 24 '26 02:02

ingsaurabh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!