I wanted to know what is the max size Room Database can take?. I don't see anything in the documentation.
Is there any option to set database size programmatically?
I have checked with documentation and couldn't find any info.
Since Room is just an abstraction layer over SQLite. Room has the same limits as SQLite
Maximum length of a string or BLOB Default size is 1 GB Max size is 2.147483647
Maximum Number Of Columns Default size is 2000 Max size is 32767
Maximum Length Of An SQL Statement Default size is 1 MB Max size is 1.073741824
Maximum Number Of Tables In A Join Default is 64 tables
Maximum Number Of Attached Databases Default is 10 Max size is 125
Maximum Number Of Rows In A Table Max Size is 18446744073.709552765
Maximum Database Size 140 tb but it will depends on your device disk size.
from sqlite doc https://www.sqlite.org/limits.html
I have wondered about the same. Since Room use SQLite underneath , here is what the SQLite database website has to say about the max size of SQLite database and its performance at huge sizes.
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).
This particular upper bound is untested since the developers do not have access to hardware capable of reaching this limit. However, tests do verify that SQLite behaves correctly and sanely when a database reaches the maximum file size of the underlying filesystem (which is usually much less than the maximum theoretical database size) and when a database is unable to grow due to disk space exhaustion.
I do not think any app will ever consume even a fraction of this size.
SQLite limits
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With