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
217
votes
20 answers

Android Gallery on Android 4.4 (KitKat) returns different URI for Intent.ACTION_GET_CONTENT

Before KitKat (or before the new Gallery) the Intent.ACTION_GET_CONTENT returned a URI like this content://media/external/images/media/3951. Using the ContentResolver and querying for MediaStore.Images.Media.DATA returned the file URL. In KitKat…
67
votes
11 answers

Convert content:// URI to actual path in Android 4.4

I tried a solution (see below) that works fine, except in Android 4.4 the call to startActivityForResult() brings up an activity titled "Open from", which has "Recent", "Images", "Downloads" as well as several apps to pick from. When I choose…
Raging Software
  • 741
  • 1
  • 8
  • 9
65
votes
5 answers

using ContentProviderClient vs ContentResolver to access content provider

The documentation on Android content providers describes using a ContentResolver, obtained from getContentResolver(), to access the content. However there is also a ContentProviderClient, which can be obtained from…
57
votes
4 answers

What is difference between contentprovider and contentResolver in android

What is the difference between ContentProviders and ContentResolver? I do not want for the SQLite database. I am developing an application for media.
48
votes
7 answers

A final answer on how to get Exif data from URI

This topic has been discussed in lots of questions here, with mostly different results and, due to API changes and different types of URIs, no definitive answer. I don’t have an answer myself, but let’s talk about it. The ExifInterface has a single…
natario
  • 24,954
  • 17
  • 88
  • 158
38
votes
4 answers

ContentProvider insert() always runs on UI thread?

I have an app that needs to pull data from a server and insert it into an SQLite database in response to user input. I thought this would be pretty simple - the code that pulls the data from the server is a fairly straightforward subclass of…
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
11 answers

Android: Distinct and GroupBy in ContentResolver

What would be the correct way to add DISTINCT and/or GROUPBY to ContentResolver-based queries? Right now I have to create custom URI for each special case. Is there a better way? (I still program for 1.5 as lowest common denominator)
Bostone
  • 36,858
  • 39
  • 167
  • 227
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…
30
votes
2 answers

what are uri, contentValues

Can anyone explain me about each term that I have used in working with calendar events? Uri event_uri = Uri.parse("content://com.android.calendar/" + "events"); What is uri here, what actually is content, as we can initialize int value to 0? Is…
AndroidDev
  • 4,521
  • 24
  • 78
  • 126
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…
27
votes
3 answers

Create/Copy File in Android Q using MediaStore

I am trying to find method which can handle create and copy of any file except Media files (Picture/Video/Audio) to copy from one place to other in internal storage in Android Q. In this I have my file created in my app folder and I want those to…
Panache
  • 1,701
  • 3
  • 19
  • 33
27
votes
7 answers

How to remove a contact programmatically in android

I try the following code to remove contact with a specified number: private void removeContact(Context context, String phone) { //context.getContentResolver().delete(Contacts.Phones.CONTENT_URI, phone, null); …
yinglcs
  • 2,891
  • 6
  • 26
  • 20
26
votes
0 answers

How to get whatsapp Contacts from Android Programmatically?

I have to try to get WhatsApp contacts from phone and I get a total Count of WhatsApp contact but from RawContacts how to get WhatsApp numbers and names that I don't know. I have tried to find a solution but can't get the exact solution for that.…
25
votes
7 answers

ContentResolver - how to get file name from Uri

I call startActivityForResult with Intent ACTION_GET_CONTENT. Some app returns me data with this Uri: content://media/external/images/media/18122 I don't know if it is image or video or some custom content. How do I use ContentResolver to get the…
Pointer Null
  • 39,597
  • 13
  • 90
  • 111
1
2 3
68 69