views:

104

answers:

1

I have an android app that periodically, say once a week downloads content from a server in XML. The content is used by the app, different Acitivities use different parts of the content.

My question is a design one, should I save the data in SQlite or just keep it as an XML file, which one would be faster to read?

The app can only use one content piece at a time, which means subsequent XML content downloads replace the old one.

+3  A: 

I'd go for SQLite if at all possible. As my experiences go XML file operations get quite slow on hand held devices (bare in mind I worked on Windows Mobile system, but I think the principle involved is the same) as the files get bigger.

Reads will be faster in a SQLite data source, however you have to decide how important that is. How frequently will this really affect the system? How much extra work will there be to get your XML files to SQLite file? Will the conversion have to take place once or every time?

I decided to go with XML for that project and I think that now, about 6 months after the project has shipped, I would have made a different choice. File operations take up to a few seconds every time and users report it as very annoying and work flow breaking. However on that project file operations occur every few minutes or so. If the interval is longer or runs in background (users don't notice it) then I don't think there are many significant advantages in using SQLite.

I suggest thinking a lot about your choices since once the project ships it is almost impossible to change your decision.

Rekreativc
okay, thanks. so, if the file is downloaded every 1o days, should i use a Timer Task then use a AsycnTask to download it or should i just implement a service?
Ngetha
@Ngetha: Since this is such a long interval, do you really think having a process/service run all the time is necessary? Are you sure the same can't be achieved with Windows Scheduler?
Rekreativc
I have just read about the alarm service and am looking into using that, do you have working experience with that?
Ngetha