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
1
vote
1 answer

How to add multiple number in existing contacts

I am able to update number in contacts using this. String where = ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ? "; String[] params = new String[] {contacts.getContactId(), …
1
vote
0 answers

My VideoPlayer Activity stopped working (VideoView)

My vidéo player activity has stop working well without any code modification for months. I don't really know when it stopped working but I feel like it's due to the ContentProvider that I added recently for 7+ compatibility on intent. The symptom is…
1
vote
1 answer

I want to retrieve the contact photo for my contacts. How do i go about it?

I am using the code below to access the phone numbers and the names of the contact. I want to add to this function a way to also add the photo of the contact. void loadContacts() { ContentResolver contentResolver=getContentResolver(); Cursor…
sahaj jain
  • 27
  • 1
  • 7
1
vote
2 answers

Android ContentObserver never stopped

I implemented a ContentObserver and it worked fine. But now everytime the ContentObserver is notified for some changes in the CallLog.Calls content provider, it runs the onChange() method without stopping. I'd like that my observer runs once for…
rogcg
  • 10,451
  • 20
  • 91
  • 133
1
vote
1 answer

How to get LOOKUP_KEY of a Contact from ContactsContract.Contacts?

I have to select a Contact from an android device Contacts list. With the following code I retrieve an activity with the list of the contacts on the device: Intent intent = new Intent(Intent.ACTION_PICK,…
MDP
  • 4,177
  • 21
  • 63
  • 119
1
vote
1 answer

Am I forced to use the Android notifyChange() method?

Am I forced to use the notifyChange() method? I ask this because, when I call this method it enters on the onChange() method, but when I don't call the notifyChange() the onChange() method is not called. Why?
rogcg
  • 10,451
  • 20
  • 91
  • 133
1
vote
1 answer

Android onChange() method only returns false

I have a ContentObserver onChange() declared as a subclasse in my activity. But it always returns false. Can anyone tell me why? (Update) This code must call the fillList if the CallLog content provider changes. I mean, if I make a new call, so the…
rogcg
  • 10,451
  • 20
  • 91
  • 133
1
vote
1 answer

Accessing appSearchData bundle from ContentProvider

An activity is supposed to be able to provide context information to a content provider like this: @Override public boolean onSearchRequested() { Bundle appSearchData = new Bundle(); appSearchData.putByte("category", category); …
1
vote
1 answer

Persistent permissions to non-SAF content

In my app, I'd like to store a persistent read permission to content provided by Dropbox (among other content providers). The Android Dropbox app doesn't support the Storage Access Framework, so to be able to select content I can't use…
1
vote
2 answers

App crashes at getWritableDatabase: NullPointerException

I'm trying to make an app that involves a database. I'm using a ContentProvider and it's crashing in the query method when it tries to getWritableDatabase. It returns a NullPointerException. I know for a fact that the Context isn't null, since that…
1
vote
1 answer

How do I get the URI of a music from the MediaStore?

I can get the artist, title and track information from the MediaStore, but how do I get the path or uri of the media file I'm trying to play?
Ragunath Jawahar
  • 19,513
  • 22
  • 110
  • 155
1
vote
2 answers

ContentProvider applyBatch is blocking UI thread

I have used applyBatch for insert,update and delete operation on SQLite database,there are more than 2000 entries for first time installation of app and for periodic sync too,due to large number of operation on database application get stop…
1
vote
1 answer

Button Push App

I am learning to make apps using Android Studio (2.3.1). First, user A on his phone pushes one of 4 colored buttons. This sends the result to user B on his phone with the exact same app, and displays the result to B (It can be a change in background…
1
vote
0 answers

ref counts can't go to zero here: stable=0 unstable=0

// Caused by: java.lang.IllegalStateException: ref counts can't go to zero here: stable=0 unstable=0 // at android.os.Parcel.readException(Parcel.java:1628) // at android.os.Parcel.readException(Parcel.java:1573) // at…
1
vote
1 answer

How do I use MockContentResolver when testing an Android Activity using Espresso?

I am using Espresso to test an Activity that displays data retrieved using a ContentProvider. I'd like to mock the content provider using MockContentProvider and MockContentResolver, but I don't know how to make the activity method…