Nicolas Raoul
Nicolas Raoul

Reputation: 60213

Max size of an Android app's in-memory SQLite database?

How large can be the database of my Android app? Is there a limit?

For performance and security reasons, I don't want to store the database on the SD card.

Upvotes: 7

Views: 2869

Answers (2)

Jon
Jon

Reputation: 9833

On Android, if your in memory database becomes too large, the app will crash. What I've found to be a safe memory limit is the size returned by getLargeMemoryClass.

http://developer.android.com/reference/android/app/ActivityManager.html#getLargeMemoryClass()

I've found that the value returned from getLargeMemoryClass() is about half of what will totally crash the app--but that is with no other apps running.

For example, running my large in-memory database app on my Nexus 7 will crash when the database exceeds about one gigabyte. On the nexus 7 (running Lollipop at least) getLargeMemoryClass() returns 512MB

Upvotes: 0

Zulaxia
Zulaxia

Reputation: 2752

As far as reading up on it would suggest, there is no hard limit on the size of sqlite db on the internal storage other than the normal limits, ie. what is spare.

However some people are reporting exceptions occurring on larger databases, though I have yet to see anyone work out why.

Sadly the internal function to report max size isn't useful for this either, it seems set at 1TB.

Upvotes: 4

Related Questions