0

I am new in Android Studio and i like the idea of having a resources files so I open a resource file (xml) in the name of integers and i put this code in him:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <integer name="omry">1</integer>
</resources>

and my code that get the var is:

Integer zomry101 = new Integer(this.getResources().getInteger(R.integer.omry));

and now i want do that if i click on a button it will add 1 to the omry int in the file, I know how to do the click event but I dont know how to change the xml file. please help.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
zomry1
  • 15
  • 4

2 Answers2

0

The res folder cannot be changed at runtime.

Aman Grover
  • 1,621
  • 1
  • 21
  • 41
0

First thing's first Resources CAN NOT be Changed or Modified once an apk has been built. You can only add values to resources that need not to be modified.

So what to do? Preferences allow you to save and modify values at run time. This SO explains how to use Shared Preferences in your app.

Have a look at this for easy to use Utility for Shared Preferences.

Community
  • 1
  • 1
Abbas
  • 3,529
  • 5
  • 36
  • 64