What happens to a Sqlite database when app is removed

前端 未结 5 1740
执念已碎
执念已碎 2020-12-15 07:11

I\'m new to Android programming and trying to wrap my head around this just to make myself clear about how things work.

When creating Sqlite databases in an Android

相关标签:
5条回答
  • 2020-12-15 07:28

    The DBs, Preferences, Cache Files, Temp Files all are stored in the location /data/data/app.package.name/ in Phone Memory.

    When you uninstall your App, the whole Phone Memory folder for this app will be completely removed.

    0 讨论(0)
  • 2020-12-15 07:28

    The database is located in /data/data/app.package.name/databases . You can access this folder only on the emulator or on a rooted device (with a file explorer with a Super user right for example).

    When you delete an app all the relative datas are deleted (databases included)

    0 讨论(0)
  • 2020-12-15 07:37

    SQlite databases are just files, and they're treated like any other file: they're stored (by default) in the application's private data area (/data/data/$PACKAGENAME/databases). They're deleted along with everything else in the application's private data area.

    You can create a database on the SD card if you like. They, of course, won't be removed on uninstallation.

    0 讨论(0)
  • 2020-12-15 07:39

    Unless stated otherwise (by you), apps keep their datas under /data/data/<appname>, and SQLite-databases are in /data/data/<appname>/databases. When uninstalling an app, the whole directory tree of /data/data/<appname> will be deleted, including your databases.

    0 讨论(0)
  • 2020-12-15 07:40

    Normally, the database would be stored in

    /data/data/package.name.of.your.app/databases
    

    However it's not a good thing to rely on this. It's much better to find it using getDatabasePath on ContextWrapper, such as:

    File dbFile = getDatabasePath(db_name);
    

    And, yes, normally the whole directory /data/data/package.name.of.your.app would be deleted if you uninstall the app.

    0 讨论(0)
提交回复
热议问题