Free Android app covering all aspects of addiction, including prevention and treatment

Accessing the database from another app

Query app iconYou use a content provider to make your database accessible to other apps.

You use a content resolver to access a database in another app.

Using the Content Provider

 

Using the content provider iconWe covered building our provider class in Part 1. Now in Part 2, we’ll see how we use the provider to access the database.

We will be accessing the database from within the app that created it but we will still use a content resolver to do so.

Building the Content Provider

This is part 1 of creating our custom content provider. This is where we build our ContentProvider class.

Building iconIn part 2, we'll show how we use the provider within the same app to access the database.

Android Content Providers

What you should know about Content providers

Content Provider iconSQLite databases can only be used by the app that created it. However you can choose to share the database with other apps if you wish.

You will need a content provider to manage access to this shared database.

It takes care of data security and communicates between the database and any app wanting to use it.