Reputation: 21
I am new to android development. I am creating an app with room persistent library. I already have a pre-populated .db file. I am able to insert and fetch my own data but I am not able to fetch already existing data from the database.
Upvotes: 0
Views: 1733
Reputation: 76952
Room doesn't support pre-populated data by default.
but I created this library which helps you to use a pre-populated database from assets folder.
and you can use it like this
final AppDatabase db = RoomAsset.databaseBuilder(
getApplicationContext(), AppDatabase.class, "your_db_name.db").build();
see the sample for example.
see this qustion for more alternatives
Upvotes: 2