Sqlite database lifecycle? It is deleted when the app is closed?

I’m following a simple tutorial that creates a class wich 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?

  • java - Google Play Game Services
  • Where can I find Android source code online?
  • Retrofit @GET - how to display request string?
  • Select item from AutoCompleteTextView in uiautomator
  • Fatal Exception: java.lang.IllegalStateException GoogleApiClient is not connected yet
  • Android Emulator: both soft input and hard keyboard input
  • Thanks

    Related posts:

    Is PhoneGap a good choice for App Development?
    onSearchRequested() no longer works in Android 4.x+?
    Attempt to re-open an already-closed object: java.lang.IllegalStateException:?
    How can I include a button in a Toast notification?
    Android: How to create a homescreen shortcut to launch a shell script?
    Choosing an ORM for Android project (min. API level 7)
  • Class 0 SMS (flash SMS) on Android
  • H2 Database vs SQLite on Android
  • Android added circle indicator to viewpager
  • “Failure Delivering Result ” - onActivityForResult
  • how to open android application if installed and go to android market if not install
  • Read SharedPreferences when you haven't set the name of the file
  • 4 Solutions collect form web for “Sqlite database lifecycle? It is deleted when the app is closed?”

    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.

    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.

    When a database is created it lives in your applications private file store and is only deleted when you explicitly delete it (using Context.deleteDatabase) or when your application is uninstalled.

    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.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.