Questions tagged [android-contentprovider]

Content providers are one of the primary building blocks of Android applications, providing content to applications.

Content providers are one of the primary building blocks of Android applications, providing content to applications. They encapsulate data and provide it to applications through the single ContentResolver interface. A content provider is only required if you need to share data between multiple applications.

For example, the contacts data is used by multiple applications and must be stored in a content provider. If you don't need to share data amongst multiple applications you can use a database directly via SQLiteDatabase

For more information about using content providers, read the Content Provider's documentation.

3206 questions
36
votes
7 answers

Insertion of thousands of contact entries using applyBatch is slow

I'm developing an application where I need to insert lots of Contact entries. At the current time approx 600 contacts with a total of 6000 phone numbers. The biggest contact has 1800 phone numbers. Status as of today is that I have created a custom…
Anders
  • 361
  • 1
  • 3
  • 3
36
votes
4 answers

Sharing via Seekable Pipe or Stream with Another Android App?

Lots of Intent actions, like ACTION_VIEW, take a Uri pointing to the content the action should be performed upon. If the content is backed by a file -- whether the Uri points directly to the file, or to a ContentProvider serving the file (see…
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
33
votes
3 answers

How to access the SMS storage on Android?

Beginner Android dev here. I'm trying to create an app that will read the SMS messages stored on the device and then give the user statistics about their habits (like who they message often, common words, etc). But to my knowledge, there doesn't…
eternalmatt
  • 3,524
  • 4
  • 25
  • 25
32
votes
4 answers

Android: SQLite transactions when using ContentResolver

The goal: refresh database from XML data The process: Start transaction Delete all existing rows from the tables Per each main element of parsed XML insert row into main table and get PK Per each child of the main element insert record into 2nd…
31
votes
7 answers

Failed to find provider info for 'ContentProvider'

I have a problem that I just cannot figure out. I am using Eclipse to create my own Content Provider but keep getting the following error: [..] ERROR/ActivityThread(1051): Failed to find provider info for …
default
  • 11,485
  • 9
  • 66
  • 102
31
votes
4 answers

Difference between ContentObserver and DatasetObserver?

What is difference between ContentObserver and DatasetObserver? When one or another should be used? I get Cursor with single row. I want to be notified about data changes - eg. when row is updated. Which observer class should I register?
pixel
  • 24,905
  • 36
  • 149
  • 251
31
votes
2 answers

Android RecyclerView + CursorLoader + ContentProvider + "Load More"

I have created one Activity in that I am implementing CursorLoader for load data from Database. I have done that thing for all records of that Table but I want to load 30-30 records like Load More Functionality I have tried to create query and its…
31
votes
3 answers

Download image from new Google+ (plus) Photos Application

Recently Google added the Photos app for Google+ (plus) and it shows up when you launch an Intent to choose an image. However, if I select an image from Google+ Photos and try to use it in my application none of my current logic is able to return a…
Jason
  • 1,238
  • 1
  • 15
  • 18
30
votes
1 answer

Google IO Rest design pattern, finished ContentProvider and stuck on getting the data from the network

After watching the very known video on this topic I decided to go with design pattern B. Using a contentprovider with servicehelper. Basically I have the following files: MyProvider MyDatabase Mycontract In the activity I can now get the…
Sam
  • 2,647
  • 2
  • 20
  • 25
30
votes
3 answers

Android. Content provider or Database?

I'm a bit confused in the question, if it's better to use ContentProvider or Database. Or it makes no difference if I don't want to share any data with other applications. If I've understood it right, content providers based on SQLite DBs and it's…
Tima
  • 12,765
  • 23
  • 82
  • 125
29
votes
4 answers

What is a Contract Class and how is it used

In the recently updated Android Dev Guide, the documentation for Content Providers contains a section titled Contract Classes. Though there is a link to an example for Contacts, it was not immediately clear what is a Contract Class and how do I…
Gurunandan Bhat
  • 3,544
  • 3
  • 31
  • 43
29
votes
3 answers

Query Android content provider from command line (adb shell)

There is a command to start an activity based on intent: am start. Also to send a broadcast: am broadcast. I think probably there should be a shell command to query a content provider, probably something like: query…
Randy Sugianto 'Yuku'
  • 71,383
  • 57
  • 178
  • 228
29
votes
5 answers

How to set up dependency injection using Dagger for things other than Activities and Fragments?

I started setting up dependency injection using Dagger as follows. Please feel encouraged to correct my implementation since I might have mistakes in there! The implementation follows the android-simple example provided by the project. In the…
28
votes
2 answers

How to implement a ContentObserver for call logs

I'd like to know if there is a way to know if the content provider of callings has changed. I mean, if I make a call, or I answer a call, it returns a "flag" that a new log has been added to the call log, or the place where Android store…
rogcg
  • 10,451
  • 20
  • 91
  • 133
28
votes
3 answers

What is cursor.setNotificationUri() used for?

I did research on how to use ContentProviders and Loaders from this tutorial How I see it: We have an Activity with ListView, SimpleCursorAdapter and CursorLoader. We also implement ContentProvider. In an Activity we can call…