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.

1031 questions
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
5 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
  • 24,905
  • 36
  • 149
  • 251
11
votes
1 answer

Android 10: fetch the gallery via MediaStore with location information

Looking at the storage access changes introduced in Android 10 here, location informations are now redacted by default. Google asks us to call setRequireOriginal() on the "MediaStore" object with the media's uri as a parameter. This works when you…
Gauthier
  • 4,798
  • 5
  • 34
  • 44
11
votes
1 answer

How is advised to use the contentResolver's delete method to be injection safe?

You can delete with content resolver by URI or by passing some parameters to the where parameter. How do you make the parameters to be SQL Injection Safe? Is it possible to use Prepared Statements with…
Pentium10
  • 204,586
  • 122
  • 423
  • 502
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
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,642
  • 2
  • 36
  • 48
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
  • 3,230
  • 4
  • 24
  • 36
10
votes
5 answers

How to Get File Path from URI in Android Oreo (8.1) or above

Expected Behavior When I am selecting the file which is stored inside "Download", it should able to retrieves its file name and path Actual Behavior When I am selecting the file which is stored inside "Download", it returns null. Steps to Reproduce…
10
votes
2 answers

Android - fast way to get hidden images and folders

For getting all images on an device I query the ContentResolver for MediaStore.Images. Now I want to add a option to show hidden files as well like many image apps like QuickPic do it. Is there a faster way than recursively searching all directories…
prom85
  • 16,896
  • 17
  • 122
  • 242
10
votes
1 answer

Android: Listening to contact changes like WhatsApp do

I'm building an App which relies heavily on the user's contacts. I've created an Account and create RawContacts on behalf of this account when needed. And I use SyncAdapter and things are great. But I'm still missing some parts of this…
10
votes
3 answers

Android - SQLite ContentResolver insert/delete/update on UI Thread?

I have looked through many examples/tutorials of using SQLite in Android. Let's say you have an app that uses SQLite, ContentProvider, CursorLoader, a custom CursorAdapter. Now all major examples of this that I've found rely on a CursorLoader to…
Leo K
  • 808
  • 1
  • 9
  • 24
10
votes
1 answer

How can make a FileProvider available to other applications?

Is it possible to have a FileProvider available to other applications ? manifest.xml ...
M'hamed
  • 2,508
  • 3
  • 24
  • 41
10
votes
2 answers

How to notify calling Activity when SyncAdapter has finished?

In my Android project I use a custom SyncAdapter which downloads data and stores it in local SQLite database. public class CustomSyncAdapter extends AbstractThreadedSyncAdapter { public CustomSyncAdapter(Context context, boolean autoInitialize)…
9
votes
0 answers

Unable to query ContentResolver to get downloaded file's name from my_downloads but works fine in all_downloads

My app is set up to activate once a file with extension .myappdata is opened. It accomplishes this through this intent-filter:
Mike
  • 5,560
  • 12
  • 41
  • 52
9
votes
3 answers

How to find and collect all the information available in a give contact in any android phone?

Currently I am displaying all the contacts of my phone in my app as a custom recyclerview. Till now I am showing name, mobile number and profile image of the contact on the list item view but I need to get all the information for that contact and…