0

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.

humazed
  • 74,687
  • 32
  • 99
  • 138
  • Hi and welcome to StackOverflow. Please refer to https://stackoverflow.com/help/how-to-ask on how to ask a proper question and improve yours according the guidelines. As a first step, please add the code you already tried and describe how it doesnt work for you. – Fabian S. Jan 18 '18 at 13:47

1 Answers1

2

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

humazed
  • 74,687
  • 32
  • 99
  • 138