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
11
votes
2 answers

ContentObserver should call if and only if ContactsContract.Contacts.CONTENT_URI changes

As my application uses content from android.provider.ContactsContract.Data (API > 11) and ContactsContract.Contacts.CONTENT_URI (API < 11) to populate Contacts. I've tried to registerContentObserver() against these provider. But it calls my…
Vikalp Patel
  • 10,669
  • 6
  • 61
  • 96
11
votes
3 answers

Read Contacts without Permission?

I want to read Contacts via Contacts Picker like this: Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI); startActivityForResult(contact, CONTACT_PICK_CODE); If I get the Result, the intent.getData() contains an uri…
Rafael T
  • 15,401
  • 15
  • 83
  • 144
11
votes
1 answer

Share an image with a content provider in Android app

I'm developing an Android app that is a gallery of images in which the images are downloaded from internet for display on the screen of smathphone. Images are displayed one at a time and the application has a button to share the image that is…
Mike
  • 163
  • 2
  • 6
11
votes
2 answers

How do I call custom method in ContentProvider through ContentResolver and access Bundle afterwards?

I have a custom method save() in my custom ContentProvider class MyContentProvider which I want to call through the ContentResolver. The objective is to pass an POJO as a Bundle through to MyContentProvider. I am using the call method as mentioned…
11
votes
7 answers

SyncAdapter periodicsync() not triggering

I'm trying ty figure out how the syncAdapter works, I used the sampleSync Adapter as an example/starting point and I based my first test on it. The only difference is that I'm not working with the default contacts provider, but that I need one of my…
rpan
  • 111
  • 1
  • 1
  • 3
11
votes
3 answers

Own ContentProvider with SQLite and multiple tables

I am reading this tutorial on implementing my own ContentProvide for working with SQLite. Int the ContentProvider.query there are a few thing that puzzles me. It seems very hardcoded to just one table (the todo table in the tutorial), but maybe Im…
Neigaard
  • 3,726
  • 9
  • 49
  • 85
11
votes
1 answer

How to grant temporary access to custom content provider using FLAG_GRANT_READ_URI_PERMISSION

I am trying to query custom content provider(App A) from another app(App B). I can do that when there is no permission protection for content provider. Specifically, I build custom content provider on App A and sent an intent containing the…
Jin
  • 113
  • 1
  • 1
  • 6
11
votes
2 answers

Write sent sms to content://sms/sent table

I am working on an android sms application.I can send sms to single contact by using the following code. sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI); Now I want to send sms to multicontacts.Some suggest to use loop.SO now I…
sarath
  • 3,181
  • 7
  • 36
  • 58
11
votes
4 answers

How to test content providers on Android

I am trying to test my DB using ProviderTestCase2. I can see the test DB being created. As such I suppose, the tested content provider should use the test DB. But as soon as I try any calls against the MockContentResolver (or the one created with…
charroch
  • 2,170
  • 2
  • 15
  • 14
11
votes
2 answers

Content Provider not working on Nexus family devices

I'm developing an app with a ContentProvider to offer some inner files (binary files). When I deploy it on a Samsung Galaxy S, SII, or any other, it works perfectly, buy when I try it on a Galaxy Nexus or Nexus S, it doesn't work! Scenario: My…
manelizzard
  • 1,060
  • 8
  • 19
11
votes
2 answers

Android ContentProvider URI scheme to notify CursorAdapters listening on OUTER JOIN queries

I have an Android ContentProvider which allows to do LEFT OUTER JOIN queries on a SQLite database. Let's assume in the database I have 3 tables, Users, Articles and Comments. The ContentProvider is something like the following: public class…
Lorenzo Polidori
  • 10,332
  • 10
  • 51
  • 60
10
votes
3 answers

onCreate of Content Provider

I found that onCreate of ContentProvider gets called first, even before the onCreate of my Activity. eg: Vogella Android SqlLite. But I wanted to know how does it happen and why? Is it because we register it as a provider in the Manifest?
Smitha
  • 6,110
  • 24
  • 90
  • 161
10
votes
1 answer

Purpose of args parameter of getLoaderManager().initLoader(...,...,...)?

Does anyone have a description of the usage of the Bundle args parameter of initLoader()? Is the object merely set on the resulting cursor or is there a way to get access to that object from the data source being queried - like a Content…
user1080691
  • 133
  • 1
  • 8
10
votes
3 answers

android sqlite "database is locked" errors despite use of content provider and sequential database access

I have an app (Android 2.2 Google API Level 8) that has multiple activities pulling data from a content provider (SELECT only database access). It also has a service with a central blocking task queue accepting any database write tasks; activities…
Eveys
  • 101
  • 1
  • 3
10
votes
5 answers

how to get contact photo URI

I am working with Android Contact ContentProvider. I have a Phone Number and I need to get the URI of the Photo of the contact associated with this phone number. How can I do it??? I know I can get the raw data of the photo and build an InputStream,…
coreSOLO
  • 3,599
  • 4
  • 20
  • 22