Reputation: 7
I build the database through the Room by this guide. This is my build code:
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
NodesRoomDatabase.class, "nodes_database.db")
.build();
And I insert information by DAO:
public void insert(NodesData nodesData) {
new InsertAsyncTask(nodesDao).execute(nodesData);
}
private static class InsertAsyncTask extends AsyncTask<NodesData, Void, Void> {
private NodesDao asyncDao;
public InsertAsyncTask(NodesDao asyncDao) {
this.asyncDao = asyncDao;
}
@Override
protected Void doInBackground(NodesData... nodesData) {
asyncDao.insert(nodesData[0]);
return null;
}
}
After database build and insert something. I can find nodes_database.db
, nodes_database.db-shm
and nodes_database.db-wal
under data/data/<package name>/databases/
but the size of nodes_database.db
is always only 4 KiB and has a empty table. But I can query all the contents of the database by using the Stetho debugging.
Device: Oneplus 5, Android Oreo 8.1
So, what's wrong with my codes?
Upvotes: 0
Views: 319
Reputation: 230
It's how SQLite works. If you want to query your database outside Android make sure to export both the .db and the .db-wal file.
Upvotes: 1