Reputation: 886
I am developing an android application, which takes user location in every 30 seconds and storing in the application's own sqlite db. In my calculation I need to store around 1 Lac records. I have only 1 table with following details, ID(Integer), latitude(real), longitude(real), date(text), time(text).
Is it safe to store the details in sqlite?
Will it cause any problem in regards to performance.
Please help me.
Upvotes: 2
Views: 3854
Reputation: 63955
SQLite's limits are usually not of interest on mobile devices. The device is by far more constrained.
For example if you add 1kB of data each 30 seconds you'll generate around 60GB of data per year. That's not going to fit on any device but would be no problem for SQLite.
Performance can be a problem if your queries are slow. Indexed queries run in some variation of log(N)
time which means that working with billions of row of data has roughly the same performance as a few thousand. If your queries are complex you can easily get into N^2 complexity or worse meaning that performance will be terrible once you reach like a thousand rows. A bit more here: http://www.sqlite.org/queryplanner.html
I would recommend to keep that size limit in mind and add a way to recycle data if there is not enough space. The internal storage (not enough space to install new apps?) is typically very limited.
Upvotes: 6
Reputation: 5234
For your question you should read this,
http://www.sqlite.org/limits.html and
http://developer.android.com/reference/android/database/sqlite/SQLiteFullException.html
and also if you are asking about it's size then i think it's 2GB, so i don't think there is any problem if you store 1 lac records or more then that, also you can try
long getMaximumSize()
to check what is the maximum size.
Upvotes: 2
Reputation: 2877
I have also worked on a similar kind of an application where i used to store user's location every second. The records count used to exceed way beyond Lacs. I was also afraid about the database errors or any such performance issues too, but, surprisingly, till date, no such issues have come forward.
I also, implemented a method to backup my database whenever the records count reached 1 billion, and refresh the database as a brand new.
To achieve this, i created another table that contains the unique ID and Timestamp of the backup database, along with its stored location on the device.
I also kept syncing every 1000 records to the webserver as a fail proof and the backup databases.
Interestingly, all this data was always in some KBs. :-)
Upvotes: 3
Reputation: 13
The maximum number of bytes in a string or BLOB in SQLite is defined by the preprocessor macro SQLITE_MAX_LENGTH. The default value of this macro is 1 billion (1 thousand million or 1,000,000,000). You can raise or lower this value at compile-time using a command-line option like this:
use this link for your help
http://www.sqlite.org/limits.html
Upvotes: 0