Maximum SQLite Database Size in Android Application

六眼飞鱼酱① 提交于 2019-12-19 02:39:26

问题


I am new to the Android Development.

Currently, I am working on one Android Application having a large amount of data.

So I have thought that I should have to store some of those data locally.

I have one database having 2 tables.

Table-1's size is: 4.5 MB Table-2's size is: 3.5 MB currently.

i.e. Totally around 8.0 MB but in future database size can be increased and may be reach to 10 MB.

Table-1: Rows(14927) and Columns(17) Table-2: Rows(9903) and Columns(38)

My doubt is that can i store this much data locally in an android application or the application's speed can be affect by it.

I don't want to store these data in external storage. And I can't store it on server database as I have to use these data many times in the application. While the other data is on server as it must be used centrally.

This is my point of view. But please give me your suggestions.

What to do if there is such size of database.

Please help me. Thanks in advance...:)


回答1:


The maximum database size can be approximately 1.4e+14 bytes (140 terabytes, or 140,000 gigabytes).

Reference: The Official SQLite Documentation and limits

14. Maximum Database Size

Every database consists of one or more "pages". Within a single database, every page is the same size, but different database can have page sizes that are powers of two between 512 and 65536, inclusive. The maximum size of a database file is 2147483646 pages. At the maximum page size of 65536 bytes, this translates into a maximum database size of approximately 1.4e+14 bytes (140 terabytes, or 128 tebibytes, or 140,000 gigabytes or 128,000 gibibytes).




回答2:


I don't want to store these data in external storage. And I can't store it on server database as I have to use these data many times in the application.

So if you don't want to use external storage, your only way is to use internal storage (also you don't want to use remote server). Usually when database has bigger size, external storage is usually used for optimizing application. But it also depends on character of data e.q. if they are sensitive or not so external storage is not always win.

But in your case i don't think that your application performance will be decreased. Only queries over your database can last longer than queries over 10-100 rows (queries can be omptimized by creating appropriate indexes).

But a few suggestions for increase performance:

  • Try to remove records which are not used for longer time
  • You can compress your data that will result in smaller db size



回答3:


You can store this much data without problem, I'm working on DB. the size of it is about 35MB. You should use caching to speed up fetching data.

I don't prefer internal storage, it's small.




回答4:


You can store this much data in sqlite.This might affect query search on your tables not your application and you should always interact with your database on separate thread rather than main thread. But you should consider removing rows from tables which are not required by user anymore,this might release some load from database.



来源:https://stackoverflow.com/questions/18459042/maximum-sqlite-database-size-in-android-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!