0

I am looking for a way to add a textview value to strings.xml file

I am not sure if this is possible,

I tried this code but it shows it as it is and it doesnt shows the value:

<string name="result">tvtxt1.getText()</string>
azza
  • 77
  • 1
  • 10

2 Answers2

2

Ressources files xml like strings.xml can only be use for read only you cannot set values dynamically, you can see it like a final variable

Vodet
  • 1,491
  • 1
  • 18
  • 36
0

When you provide a data as a Resource, it can't be modified during run time. This applies to Strings.xml, Drawables, Values etc.. You should consider to create a separate class and have your strings placed in this Class and access them.

I suggest to use a ViewModel, you can save your strings inside of it and you can be sure that you will not loose them when your view will be recreated for some reason