Dep
Dep

Reputation: 41

SQLiteDatabase vs File storage

I want to store structure type data (i.e. information of call logs like name, number, type of number, date, time, duration). Which is the best way and which is faster? SQLiteDatabase (make table and insert, delete logs in it) or use file storage (means make one class for all parameters and write their objects in file using input/output Stream and serializable) or the another way i heard about it is XML parser but i don't know this.

Please help me. Thanks in advance.

Upvotes: 4

Views: 1291

Answers (4)

ttt
ttt

Reputation: 6809

In my experience in most cases JSON in a file is enough (mostly you need to store an array or an object or just a single number or string). I rarely need SQLite (which needs more time for setting it up and using it).

Upvotes: 0

riwalk
riwalk

Reputation: 14223

It depends on what you are trying to do.

If your goal is speed, the SQLite will give you a serious run for your money (especially if you wrap multiple inserts into transactions). SQLite has been optimized for everything you mentioned and it would be very easy to leverage the speed it can give you.

If portability is your goal, then files may be a slight bit easier. Files can be moved back and forth very easily easily, whereas SQLite might take some more effort.

If being able to search is your goal, then you'd be a fool not to use SQLite, as it is extremely good at searching and filtering results.

Upvotes: 3

Tommy
Tommy

Reputation: 1267

Personally, given you know the basics of Databases I would use a sqlite database. It's pretty straight forward in Android. In terms of speed I don't know which is faster, but if you don't have millions of datasets it won't matter.

Upvotes: 0

Amplify91
Amplify91

Reputation: 2660

I can't give a very informed answer here because I'm just as new to the subject as you are, but here is the link from the developers page that goes over the different types of data storage. I hope you find it useful. http://developer.android.com/guide/topics/data/data-storage.html

Upvotes: 0

Related Questions