Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there no database file created when using Android Room?

I use the Room Persistence Library for my Android app, but after it's creation I can not find .sql file with tables on my device.

When I create database through SQLiteOpenHelper I can see all my tables in folder data on the device, but when I create database through Room there is no file anywhere.

Where can I see the content of all my tables?

Create database code:

@Provides
@Singleton
PokuponDataBase providePokuponDataBase() {
    return Room.inMemoryDatabaseBuilder(SuperDealApp.getInstance().getApplicationContext(), PokuponDataBase.class, "PokuponRoomDatabase").build();
}
like image 676
WorieN Avatar asked Jul 05 '17 12:07

WorieN


People also ask

How do I find the room database file on my Android phone?

Go to Tools -> DDMS or click the Device File Explorer below Layout Preview in right bar. Device Monitor window will open. In File Explorer tab, click data -> data -> your project name -> databases . Click pull a file from device icon.

How do I find my room database?

Go To App Inspection . Then select the process. Database Inspector will now show the database contents. in 2021, with current Android Studio, this should be the only accepted answer.

Is there a database on Android?

database. Contains classes to explore data returned through a content provider. If you need to manage data in a private database, use the android.


1 Answers

I found the cause of disappearing my database. It was because I create it incorrectly. I use Room.InMemoryDatabaseBuilder() instead of simple Room.databaseBuilder() and after each application reloading my db was recreated and also inMemory database does not create any files.

like image 68
WorieN Avatar answered Oct 13 '22 06:10

WorieN