Search code examples
javaandroidxmlandroid-contentprovider

Using XML file as android application data holder


I have developed app which holds data in .xml file in res/xml/myfilename.xml and binds all the data to expandable list view.

XML structure:

<companyes>

<company>
<name> </name>
<employees>
<employee>
(employee parameters)
<employee>
</employees>
</company>

...

</companyes>

Now I am trying to implement data editing/deleting feature and I have found out that it seems to be impossible (using structure like this): you can not edit resources nor assets folder content on runtime. Is this true?

Is it possible to solve this problem by using structure like I use (XML for data holding)? Or should I use some other method? contentprovider? (Im new in android development and haven't got to the part where content provider is disgussed)


Solution

  • Correct you can not modify the data inside of your application. Your .apk is immutable. You need to store this data in your persistent storage (in a database or a raw file) available through Context.