简体   繁体   中英

How to convert xml to sqlite database in android platform?

I have a xml file with info inside. I want to convert the xml file to sqlite database without using a SD card in android platform(Java Language). Does anyone have any idea how to do it?

You can use parser(DOM, SAX, JSON) for update sqlite database using the XML file. Put your xml file in the assets folder and then read with help of Asset Manager. For more info about this refer below links.

[http://www.androidhive.info/2012/05/android-rss-reader-application-using-sqlite-part-2/][1]

http://martin.cubeactive.com/android-filling-a-table-from-resource-file-using-xml-sqlite/

Sure!

There should be a folder called assets in your project folder. Put your XML file inside that folder and use Resources.openRawResource(int id) to grab an input stream for your XML file. Having done this before, I suggest that if your XML file is of significant size, use an event-based XML parser so you can read your XML in pieces instead of loading it in memory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM