Questions tagged [android-contentresolver]

A ContentResolver represents the connection between an app requesting data and the target ContentProvider.

A ContentResolver represents the connection between an app requesting data and the target ContentProvider. A typical way to access the ContentResolver is through the getContentResolver() method of an Activity.

965 questions
12
votes
2 answers

How to get media item real_Path from contentResolver.openFileDescriptor(Uri uri, String s) in Android Q?

MediaStore.MediaColumns.DATA constant was deprecated in API level Q. Apps may not have filesystem permissions to directly access this path. Instead of trying to open this path directly, apps should use ContentResolver#openFileDescriptor(Uri, String)…
12
votes
1 answer

Calling delete method in custom content provider

I am learning Android and I am stuck on an issue involving calling a custom content provider. I have been using an example in an instructional book and although it describes how to create the custom provider there is no clear example how to call the…
12
votes
1 answer

SyncAdapter always in pending state

I'm currently working on an android app which relies on a SyncAdapter to refresh its content from a server. I basically followed these instructions: https://developer.android.com/training/sync-adapters/creating-sync-adapter.html This worked…
12
votes
4 answers

Android Create Playlist

Anyone know how to add playlists to Android in code? I kind of get that I have to insert it into the content resolver but do I have to just put the song id in or do I have to put all of the song's data in? I have been looking for sample code but…
shaneburgess
  • 14,832
  • 15
  • 44
  • 65
12
votes
5 answers

Failed to find provider info error

I am trying to have a contentprovider , but I am having trouble because I am getting an error of "Failed to find provider info for com.example.alex.hopefulyworks" Here is the manifest and the contentprovider
12
votes
3 answers

Android fetch all contact list (name, email, phone) takes more then a minute for about 700 contacts

Is there any way to shorten this time? I'm running with the cursor and takes the name, phone numbers and emails if I remove the phone numbers query from the query loop it ends in 3 seconds any idea how can I improve that query? Maybe I'm doing…
itay83
  • 390
  • 1
  • 5
  • 18
12
votes
2 answers

is it possible to replace the MediaStore with a test double using robolectric?

I have a class that queries the MediaStore for images. For example, I have code that looks like someContentResolver.query( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, ... ). I want to test that, among other things, my queries to the MediaStore…
12
votes
1 answer

How to load a Picasa image from URI?

I'm using ACTION_PICK intent to select an image from gallery. Some albums like "Posts", "Profile Photos", etc are marked with Picasa icon. For images from such albums I get a URI similar to…
12
votes
2 answers

Android get sms from inbox, optimized way to read all messages and group them

Hi am implementing a SMS App, now am able to retrieve all messages with their respective contact info like display name, photo uri.. and am displaying them in a custom list where on item click takes you to respective discussion. Here my issues is…
12
votes
2 answers

How to properly insert values into the SQLite database using ContentProvider's insert() method through a CursorLoader?

I was reading the doc, but I am still not too sure. Its says to use getContentResolver(), but then that really isn't using CursorLoader. So is there a way to do it through CursorLoader? I know how to do it with query(). Are the steps very similar?…
11
votes
7 answers

Android: getContext().getContentResolver() sometimes gets NullPointerException

I want to ask why we get this annotation: Method invocation getContext.getContentResolver() may produce NullPointerException Why is it there and not in other parts of program Fragment/Activity? That approach has been used in tutorial made by…
Radek O
  • 398
  • 1
  • 3
  • 12
11
votes
1 answer

ContentResolver usage

I am new to andriod domain and is in learning phase. I got couple of queries: Do we have single ContentResolver object per app? Is it a singleton object? Who manages this object lifecycle? If it's singleton, how does it handles multiple request of…
loc
  • 115
  • 1
  • 7
11
votes
1 answer

SyncAdapter running animation - how to know if SyncAdapter is actively synchronizing

I want to show a ProgressBar in the ActionBar while my SyncAdapter is actively synchronizing content to and from the web. I have tried using the SyncStatusObserver together with ContentProvider.addStatusChangeListener. However, I cannot check if a…
foens
  • 8,422
  • 1
  • 31
  • 47
10
votes
4 answers

Android - Find a contact by display name

I'm trying to find a contact by display name. The goal is to open this contact and add more data to it (specifically more phone numbers), but I'm struggling to even find the contact I want to update. This is the code I'm using: public static…
Bjarte Aune Olsen
  • 2,900
  • 3
  • 20
  • 35
10
votes
4 answers

How to test class using content resolver/provider?

I'm trying to test class that queries content resolver. I would like to use MockContentResolver and mock query method. The problem is that this method is final. What should I do? Use mocking framework? Mock other class? Thanks in advance. public…
pixel
  • 21,352
  • 30
  • 113
  • 196
1 2
3
64 65