0

I am loving the flexibility offered by ContentProvider, obviously ContentProvider is the favored route to go for an Android database, however, how does one efficiently populate the resulting database?

For instance, let's say I am creating an RSS reader with links to 100 feeds. The feeds themselves should be in the database at launch, how would I populate these feeds into the database?

Would I have to write 100 queries based on getContentResolver.insert() to do this? That approach seems complicated and unnecessary.

Moreover, how would one review the database content created to ensure things are going as planned? I can't simply find the database like one would with a SQL database created for the app.

Thank you for the suggestions!

AutoM8R
  • 3,020
  • 3
  • 32
  • 52
  • possible duplicate of [How to ship an Android application with a database?](http://stackoverflow.com/questions/513084/how-to-ship-an-android-application-with-a-database) – Rajesh Feb 15 '15 at 18:01

1 Answers1

0

obviously ContentProvider is the favored route to go for an Android database

You are welcome to your opinion.

how does one efficiently populate the resulting database?

In terms of pre-population, you would do it the same way that you would pre-populate a database that is not fronted by a ContentProvider. I would recommend that you use SQLiteAssetHelper.

I can't simply find the database like one would with a SQL database created for the app.

Since you are the one creating the database and the ContentProvider, you most certainly know where the database is and what you named it.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I suppose I don't understand ContentProvider fronted databases. I didn't actually create a database, I used SimpleProvider to do so, so I guess I need to understand where SimpleProvider puts this database to download it to my harddrive. I appreciate the recommendations, I'll look more into the mechanics of this. – AutoM8R Feb 15 '15 at 19:38
  • @AutoM8R: "I used SimpleProvider" -- then you will need to take this up with the author of that library. If you are referring to [this library](https://github.com/Triple-T/simpleprovider), it is open source, and so you can always attempt to make sense of its implementation. That being said, it may be tricky to ship a pre-populated database when you are not in charge of the database. You may wind up having to use your `insert()` statements (or a `bulkInsert()`) instead. – CommonsWare Feb 15 '15 at 19:40
  • thank you very much, that helps a great deal. I should have mentioned more of the specifics upfront, I will do so in the future. – AutoM8R Feb 15 '15 at 19:47