Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Database Inspector always showing database as "closed"

I am trying to use Database Inspector in Android Studio. Why I run the app on the device, it inspector is always showing my application database (highlighted in the image) as "closed".

Is there any fix for this or did I miss something during the setup?

enter image description here

like image 292
Wamiq Avatar asked Nov 29 '20 08:11

Wamiq


People also ask

How do I know if my Android database is empty?

To determine whether an SQLite database file is empty, execute the following query: SELECT COUNT(*) FROM sqlite_schema; You will get the number of objects (tables, indices, views, triggers) in the database or 0 if the file is empty.


1 Answers

UPD. last time I had this annoying issue Invalidate cache/Restart fixed this for me. Sigh

Running the app in Debug mode enter image description here (Win: Shift+F9 or Mac: Control+D) does the magic for me sometimes.

Not sure if this is a bug or not. The android documentation doesn't mention on this, so I guess it should just work in normal mode, but for some reason doesn't for me..

I use (Android Studio 4.2 beta 3). Property minSdkVersion set to 27.

I don't use Room or any other ORM, just a few plain simplest queries.

The toggle 'Keep database connection open' doesn't seem helping either.

In normal mode:

enter image description here

In Debug mode (what I want):

enter image description here

Noticeable, that it continuing to work (querying the database etc) even after I stopped the app running in Debug mode:

enter image description here

like image 148
exenza Avatar answered Oct 20 '22 19:10

exenza