开发者

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 runtim开发者_运维百科e. 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)


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.


My two cents: I experienced the same kind of issue some times ago (+ I have to share the underlying data between several applications). I finally used a ContentProvider with à SQLite database and manage xml to SQLite back and forth conversion on desktop.

I suggest to use a sqlite database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜