2

I have my category_array(String array) in my String.xml file. I use this string-array to populate a listview.

<string-array name="category_array">
    <item >Airplane</item>
    <item >Train</item>
    <item >Taxi</item>
    <item >Bus</item>
    <item >Food</item>
    <item >Drink</item>
    <item >Meeting Entrata</item>
</string-array>

Can I add an item getted from an editText from my Activity, to my category_array??

5 Answers 5

2

Its not possible, strings.xml file is read-only. you can't edit this file at run-time.

Sign up to request clarification or add additional context in comments.

Comments

0

No, resources aren't editable. Use database instead.

Comments

0

No, you cannot add items to a string-array dynamically. What you define in resources is always what you will get.

Resources are defined as public static final in R.

Comments

0

Nothing can be added in String.xml during runtime. For every item in string.xml.Android SDK provides a static integer during compile.i.e., in R.java file. So you can edit it during runtime if you need to any item during runtime i prefer you to use either ArrayList or Map

Comments

0

You can not add data xml dynamically its used for static data which are not going to change in entire project.

Vector<String> vecString=new Vector<String>();

Then you can add strings dynamically...

vecString.add("Your Item1");
vecString.add("Your Item1");

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.