Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When does SQLite save its cache to disk? (on Android)

Tags:

android

sqlite

I work with db (without content provider), and I'm interested to know when data will be written to the SD card. Does it happen immediately after method is call (Ex: insert, update) or is there a buffer in between the only writes occasionally, or when the buffer is full? (do I need have some method for saving the DB in onPause, or it's will be work correctly anywhere?)

P.S. the DB is closed when the application exits.

like image 967
jathpr Avatar asked Mar 09 '26 16:03

jathpr


1 Answers

Does it happen immediately after method is call (Ex: insert, update)

Yes. More accurately, it happens immediately upon completion of the transaction. If you are not using your own transactions, each insert/update/delete/execSQL call is its own transaction.

or is there a buffer in between the only writes occasionally, or when the buffer is full?

No.

like image 182
CommonsWare Avatar answered Mar 12 '26 07:03

CommonsWare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!