can not inspect database from App Inspector on Android Studio when using Drift #1818
Replies: 4 comments 6 replies
-
I've moved this issue into a discussion because that might improve visibility :) As an alternative to import 'package:sqflite/sqflite.dart' show getDatabasesPath;
final database = LazyDatabase(() async {
final dbFolder = await getDatabasesPath();
final file = File(p.join(dbFolder, 'db.sqlite'));
return NativeDatabase(file);
}) Then you're still guaranteed to get the latest sqlite3 version across all devices but it should show up in the builtin database explorer. Alternatively, you can also use the storage_inspector IDEA plugin to view and inspect drift databases easily. |
Beta Was this translation helpful? Give feedback.
-
i have the same issue is there any problem or drawback with using |
Beta Was this translation helpful? Give feedback.
-
Sorry, but I don't get it :-( I use the simple isolates setup with a Do I need this I can't use the |
Beta Was this translation helpful? Give feedback.
-
App Inspector is a very much helpful tools which comes with Android Studio to inspect SQLite database.
When using ROOM, SQLite or floor lib for database, I can able to monitor my database from app inspector (even moor older version of drift). But when using new Drift, inspector shows nothing.
After investigating I have come to know that, when using -> dbFolder = await getApplicationDocumentsDirectory() and return NativeDatabase(file) for creating database, no Databases folder was created in the app directory of mobile/device. Database file (for my example db.sqlite) was created inside app_flutter folder, hence app_inspector was not show anything.
Then I follow the moor database structure and database creation and found SqfliteQueryExecutor.inDatabaseFolder. For that we also need
drift_sqflite: ^1.0.0 (older version of drift) package. Now I just check platform for Android then return SqfliteQueryExecutor.inDatabaseFolder(path: DB name);
By doing this now Databases folder is created inside app directory of the device and database file also created inside the Databases folder.
Now i can inspect my app database by using app_inspector when using new Drift package.
Beta Was this translation helpful? Give feedback.
All reactions