Specify max sqlite db size for my app. How to handle db full exception

Viewed 5085

I was asked in an interview how can we set max size for sqlite db for our android app. And how can we handle when max size is reached?

EDIT: Marina Lynn's answer below seems acceptable to this question. But Are there some sort of listeners which are triggered when the db size reaches near the limit we have specified? (Or something like this)

3 Answers

Pls take it to consideration SQLiteFullException will be throw not only when you database reach it's own limit but also in situation there is no free space in file storage. If you want to handle SQLiteFull exception you also need to check free space on the device. If it out of space on the device you need to tell to user to clear device from unused data.

Related