In this small article, I’ll show you how you can see the data in SQLite DB of your flutter application. In the previous two articles, we’ve covered SQLite CRUD Operation in Flutter App.

Credit to Stack Overflow answer here.

Where is Databases are stored ?

When you create an SQLite DB programmically, did you thought about physically location of the DB? If you are coming from web development, you might look into project explorer for a file with the extension ‘db’. But it’s not in the project directory.

It depends on the environment – android or IOS. To find the location of the database we’ve used a package path_provider in previous article. The db will be stored somewhere in the emulator. To see the path I’ve added the print statement in _initDatabase method of DatabaseHelper class.

_initDatabase() async {
    String dbPath = join(dataDirectory.path, _databaseName);
    print('db location : '+dbPath);

Now to see the printed output, If you are on VS Code, open Debug Console ( from view menu ). In my case it prints as follows.

View SQLite DB physical location

Connect to the SQLite DB

Now connect to the emulator throughadbcommands. As per android.developer, It a command-line tool, that let’s you communicate with a device/ emulator. this tool will be there inside platform-tools folder in your android sdk path. sdk path will be shown in android studio > sdk manager.

Now navigate inside the sdk location and then inside the platform-tools folder. where you could see adb.exe. Execute following command from command prompt.

# View all of your emulator
adb devices
# Connect to your selected emulator
adb -s [emulator_name] shell

Now find your package name. It’s there in AndroidManifest.xml( file as package name.

Now run as the package. from the previous command prompt.

run-as [package_name]
# [package_name] = com.example.sqlite_crud

# Now navigate inside the folder where the db is stored
# which is the location printed from our app
cd [db_path]
# [db_path] - '/data/user/0/com.example.sqlite_crud/app_flutter'

# Connect to the db using sqlite3
sqlite3 [db_file]
# [db_file] : ContactData.db

# Now execute sql queries to view data inside the db.
# select * form contacts;

Hope you find this helpful. End.

Step By Step Video Tutorial