I know it is possible to use .getResources() to load XML data into a string array, but how do i do the opposite? I want to add an array to an XML file and save it.
-
Why? I assume you want to save same user data so [sharedPreferences](http://developer.android.com/reference/android/content/SharedPreferences.html) should be ideal – Diolor Apr 22 '14 at 01:21
-
i have information in my app, i want the user to be able to add his own information to the list. the pre populated list is in xml form – pfortyseven Apr 22 '14 at 01:23
-
its a cards against humanity theme. we have some cards in an XML file, i want the user to be able to add his own card combination. then the app will load it. – pfortyseven Apr 22 '14 at 01:24
-
i dont see why if you can load resources from xml why you cant create more in java. that makes no sense – pfortyseven Apr 22 '14 at 01:26
2 Answers
you can not write data in a xml file at runtime located in your res folder.
There are 5 options to save data at runtime
1) Shared Preferences: Store private primitive data in key-value pairs. 2) Internal Storage: Store private data on the device memory. 3) External Storage: Store public data on the shared external storage. 4) SQLite Databases: Store structured data in a private database. 5) Network Connection: Store data on the web with your own network server.
Shared Preferences is used when you have small data. Internal Storage or External Storage can used for saving files like image, text file etc. SQLite Database can be used to store contact numbers, area name and Network Connection is used when you have client server situation like for data entry application.
Read more here http://developer.android.com/guide/topics/data/data-storage.html

- 63
- 6
What you want isn't possible but I would recommend looking at this question. SharedPreferences
is probably what you're looking for but depending on your goals you could simply save to a text file.

- 1
- 1

- 415
- 6
- 21