I'm following a simple tutorial that creates a class which extends from SQLiteOpenHelper and creates a DB with one table and 5 rows.
OK, but I need to understand some more about android Sqlite databases. For example, what happens if the app is closed or the phone is off? Is the database deleted?
Of course the database isn't deleted. I assume you're doing it the "proper" way. In which case the database is persistent. (of course if you choose to create a database in a temporary directory or something similar then its not going to work properly).
Think of it like this. The database is basically a text file. What you're doing to the database is modifying the contents of that text file (ok its a little bit more complicated in real life, but its a good way to think about it).
Once you've made a change to the database (e.g. added a row) the database file is saved onto the disk thus persisting it. If the phone is turned off or the app is quit then the database file persists and you can keep connecting to it in the future.
The database is deleted only when your app is deleted, the user clears the data associated with it or you do it programmatically.
Therefore, your app can be killed or the phone rebooted and your database persists. That's why database is considered to be a persistent storage.
what happens if the app is closed or the phone is off?
Answer is No, database not deleted, your data is only deleted when you Uninstall
the Application or Clear data
from Application->Manage Application->Application_Name
from your device.
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