• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

resource file strings.xml change data

 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one question for the resource files of an android app, i can read a value from the file, but is it possible to change that value in the file?
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you cant modify the res folders file.
 
David Freitag
Greenhorn
Posts: 13
Android C++ Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you are asking whether you can modify the strings stored in the "strings.xml" file in your code like you could manipulate any other string stored as a variable..

The answer to that question is No. Those values are Constants, IE they cannot be modified unless you open the file in eclipse and manually change them.

If you want Strings and String-array's that are modifiable while the program is running, then you will need to create and modify them within the java portion of android.

Pseudo code:


An extremely simple example but you get the point.

If you mean actually opening the "strings.xml" file in eclipse? then yes, it is completely modifiable, its just that you need to use the proper syntax to create the variables.

Pseudo code:


just paste that into strings.xml, just make sure that strings.xml begins with

and ends with


To use a string or string-array defined in this file, or any other file like this, use


If you aren't sure where to put that code, hit "Ctrl + f" on your keyboard, and search for

and paste it into the end of the constructor.

if you don't know what LogCat is, in Eclipse click Window -> Show View -> Other... a window will pop up, maximize the folder "Android" to the left and select "LogCat" and click Ok.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic