I'm currently creating an Android application that uses a prepackaged database. The database is initially around 40MB in size and is stored in the assets/databases folder.
The Problem
When I look up how much space my application is using, the "App Info" page shows the following:
- App Size: ~25mb
- User Data: ~3mb
- Cache: ~45mb
I believe that ROOM is causing this because of the following reasons:
- I'm not caching anything in my application (Double checked using the Device File Explorer).
- This problem started happening when I migrated from SQLiteOpenHelper to Room
- The size of the database is much greater than the App Size, but it is around the same as the Cache size so whatever is stored as Cache must be related to the database.
- Whenever I add/remove indices from my Entities, the Cache size changes.
- When I clear the cache and open the app, the Cache size reverts back to ~45mb.
Is it normal for Android ROOM to be storing the prepackaged database as Cache? Any help would be much appreciated and let me know if you need more information.
Thank you
EDIT (Additional Information)
This is what I see in the Device File Explorer
And this is how I'm implementing the Room database
@Database(entities = {/* entities*/}, version = 1, exportSchema = false)
public abstract class MyDatabase extends RoomDatabase {
public abstract MyDao myDao();
private static volatile Database INSTANCE;
public static Database getDatabase(final Context context) {
if (INSTANCE == null) {
synchronized (MyDatabase.class) {
if (INSTANCE == null) {
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
MyDatabase.class, "database")
.createFromAsset("databases/database.db")
.build();
}
}
}
return INSTANCE;
}
}