-1

right now I am creating an app which should get userinput via an EditText and then store this String into the strings.xml file. Can one of you tell me how to do this?

  • post some code and where are you stuck... This is too broad to answer and shows lack of investigation – Ivan Dec 21 '17 at 14:41
  • This is not the way strings.xml works. You need to find an other way to do that. – Eselfar Dec 21 '17 at 14:42

1 Answers1

1

You cant put a string inside the strings.xml as it is read only. you can put it in shared preferences though

SharedPreferences.Editor editor = getSharedPreferences("MyPrefs", MODE_PRIVATE).edit();
 editor.putString("input", "My String");
 editor.apply();

and to get it back

SharedPreferences prefs = getSharedPreferences("MyPrefs", MODE_PRIVATE); 
String restoredText = prefs.getString("input", null);
Tomer Shemesh
  • 10,278
  • 4
  • 21
  • 44
  • 1
    Yeah this is the easiest solution. But depending on what OP wants to do, it could be better to use a database. – Eselfar Dec 21 '17 at 14:45