flutter sqlite database storage location

1,673

I found the solution that works on Android. It is possible to extract the database file by using adb.

  1. Connect the phone via USB
  2. use the adb shell
  3. type run-as *mypackage*.*app-name*
  4. you are in the /data/data/*mypackage*.*app-name* folder
  5. cd into the databases folder
  6. copy the database file (i.e. cp doggie_database.db /storage/self/primary/Documents)

Use these 2 articles as reference:

https://denniskubes.com/2012/09/25/read-android-data-folder-without-rooting/

https://blog.shvetsov.com/2013/02/access-android-app-data-without-root.html

Share:
1,673
Ole
Author by

Ole

Updated on December 25, 2022

Comments

  • Ole
    Ole over 1 year

    I want to have an SQLite db in my flutter app, so i followed this flutter cookbook: https://flutter.dev/docs/cookbook/persistence/sqlite

    I open the database with the following path: join(await getDatabasesPath(), 'doggie_database.db') exactly like the tutorial. I ran the app on my Android phone (not emulator).

    Now i want to inspect the database file on my PC, but i cannot find the file on my phone.

    I debugged the above statement and it resolves to /data/user/0/*mypackage*.*app-name*/databases/doggie_database.db, but i can't find the folder /data (only Android/data) or the file in my file manager neither on my phone nor on my pc.

    Where is the file and how can i extract it from my phone?

  • Ole
    Ole over 2 years
    cp now doesn't seem to work any longer. did it using this answer now: stackoverflow.com/a/51780059/12949885