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
217
votes
19 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 quering for MediaStore.Images.Media.DATA returned the file URL. In KitKat…
64
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…
64
votes
8 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
  • 711
  • 1
  • 8
  • 9
50
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.
42
votes
5 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
  • 23,696
  • 13
  • 82
  • 148
36
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…
35
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
  • 351
  • 1
  • 3
  • 3
34
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
  • 34,822
  • 38
  • 158
  • 216
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,331
  • 21
  • 73
  • 123
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…
26
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,613
  • 5
  • 24
  • 20
23
votes
1 answer

Inserting a video into MediaStore

I'm trying to insert a video into the MediaStore, the same way it's possible to store an image using this method: MediaStore.Images.Media.insertImage(getContentResolver(), imagePath, null, null) Since there's no similar method on…
Juan Andrés Diana
  • 2,185
  • 3
  • 22
  • 36
22
votes
2 answers

How does getContentResolver() work?

I watched a course about ContentProvider on the Internet demonstrating how to define and use a ContentProvider. I was confused about using the method named getContentResolver(). What does this method return? My ContentProvider is not instanced and…
Huang Jie
  • 715
  • 2
  • 8
  • 22
22
votes
1 answer

Android Contacts provider get only phone contacts with all emails

I need to get all phone contacts and their email address and photo uri: This is what am doing: private void getContacts() { ContentResolver cr = getContentResolver(); Cursor cur = cr.query(Contacts.CONTENT_URI, null, null, null,…
1
2 3
64 65