Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

resource file strings.xml change data  RSS feed

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?
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you cant modify the res folders file.
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.
Amateurs built google. Professionals built the titanic. We can't find the guy that built this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!