Search code examples
androidsqlitefilesystemsandroid-contentprovider

Content Provider for Storing files in disk as well as info in db


I am building an application which would store some information into the database and store some information in disk. I was just wondering on how should I be doing this?

Do Content Providers work for Databases only or can be used to retrieve stuff from disk? I plan to use a Content provider since I might want my data to appear in Global Search etc..

So, basically I would like to retrieve information from the database as well as disk everytime. If I can use a content provider for accessing things from disk, should I know be having two content providers or just one (which accesses SQLite as well as disk)


Solution

  • In the query method of your content provider you can fetch data from the disk/net and then return them building a MatrixCursor.

    Here a basic example from the android doc.