IntelliJ Java IDE
The moose likes Android and the fly likes resource file strings.xml change data Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Mobile » Android
Reply Bookmark "resource file strings.xml change data" Watch "resource file strings.xml change data" New topic
Author

resource file strings.xml change data

Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 132

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

Joined: Jul 15, 2008
Posts: 623

I think you cant modify the res folders file.


Life is easy because we write the source code.....
David Freitag
Greenhorn

Joined: May 28, 2011
Posts: 13

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.
 
IntelliJ Java IDE
 
subject: resource file strings.xml change data
 
Threads others viewed
Dynamically load properties file
How to know about MessageResources.properties file?
property file dynamic vs static
Using Multiple resource file without using the bundle keyword?
How to write customized Tag handler in Struts 2
developer file tools