Sqlite database life cycle? Is it deleted when the application is closed?

I am following a simple tutorial that creates a class that extends from SQLiteOpenHelper and creates a DB with one table and 5 rows.

OK, but I need to know a little more about Android Sqlite databases. For example, what happens if the application is closed or the phone is turned off? Is the database deleted?

thanks

+6
source share
4 answers

Of course, the database is not deleted. I assume that you are doing it "right." In this case, the database is permanent. (of course, if you decide to create a database in a temporary directory or something similar, then it will not work properly).

Think of it this way. A database is basically a text file. What you do with the database is changing the contents of this text file (leave it a little more difficult in real life, but this is a good way to think about it).

After you make changes to the database (for example, add a line), the database file is saved to disk, thereby saving it. If the phone is turned off or the application is completed, the database file is saved and you can continue to connect to it in the future.

+10
source

What happens if the application is closed or the phone is turned off?

Answer No, the database is not deleted, your data is deleted only with the Uninstall application or Clear data with Application->Manage Application->Application_Name from your device.

+4
source

When a database is created, it lives in your private storage of personal application files and is deleted only when it is explicitly deleted (using Context.deleteDatabase ) or when your application is deleted.

+3
source

The database is deleted only when your application is deleted, the user clears the data associated with it, or does it programmatically.

Therefore, your application may be killed or the phone rebooted, and your database will be saved. Therefore, the database is considered permanent storage.

+3
source

Source: https://habr.com/ru/post/907482/


All Articles