MoZZoZoZZo
MoZZoZoZZo

Reputation: 243

How to populate Content Provider without a DB

In my Android application, I'm using an Intent-based third party library application. The 3rd party lib requires a Content Provider containing the data generated from my app.

Unfortunately, my app doesn't use db or any kind of persistence: data is totally volatile. As a consequence, the Content Provider has no db to fetch data from.

Ideally I'd like to pass data to the Content Provider when the Android runtime instanciates it. Is there a way to achieve this?

Thanks regards Vincenzo

Upvotes: 1

Views: 806

Answers (1)

Akhil
Akhil

Reputation: 14058

You will need to use a MatrixCursor. It is a mutable cursor and you can add rows at runtime. Pass this cursor to your ContentProvider and it would like a normal db cursor. You can search google for examples.

Upvotes: 1

Related Questions