开发者

Store and Parse XML from the internet

I'm trying to find the best way to store XML files from the internet, so that i can parse them at a later date. I have no problems with downloading an xml fi开发者_如何学Cle, and storing it in the

/data/data/package_name/files

folder. However i'm not sure how to read this file after it has been saved there, and to pass that read file to an instance of a SAX Parser. Additionally, i have noticed that it is quite slow to read the file from the phone, which is a concern.

I have read the storing XML files in the res/xml folder is a lot quicker - but i'm not sure if it's possible to save a file from the internet into this folder at runtime?

Any help would be appreciated :)

Cheeers


Store it in the cache directory.

getCacheDir();

so you can say filename = getCacheDir() + file123.xml;


You cant write to the res folder at all. These resources are compiled into your app at build time and are read only. As for reading the file, You should just be able to create an input stream for it in the standard java way and parse out the bytes using your sax parser.

This section of the guide describes how to access the internal and external filesystems and how to get input/output streams. http://developer.android.com/guide/topics/data/data-storage.html#filesInternal

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜