android-contentresolver

Trouble writing internal memory android

做~自己de王妃 提交于 2019-12-18 12:45:46
问题 void launchImageCapture(Activity context) { Uri imageFileUri = context.getContentResolver() .insert(Media.INTERNAL_CONTENT_URI, new ContentValues()); m_queue.add(imageFileUri); Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri); context.startActivityForResult(i, ImportActivity.CAMERA_REQUEST); } The above code, which has always worked, is now generating this exception for me at insert(). java.lang

registerContentObserver() on raw SQLite Cursor

夙愿已清 提交于 2019-12-18 10:55:09
问题 All of the examples I've seen of using registerContentObserver() do so through a ContentProvider interface. But Cursor has a registerContentObserver() call, so I figured maybe the Android folks have put together some deep magic that would allow for getting updates on a SQLite cursor when one of the rows from an active result set changed. Either I'm doing it wrong, or there is no such magic. Here's the code I'm working with, the expectation being that when I click on the button to update the

Get file path from URI

♀尐吖头ヾ 提交于 2019-12-17 22:37:40
问题 I have Uri for Image file. I use this code for gets file path from Uri: public String getRealPathFromURI(Uri contentUri) { Cursor cursor = null; try { String[] proj = { MediaStore.Images.Media.DATA }; cursor = mContext.getContentResolver().query(contentUri, proj, null, null, null); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } catch (Exception e) { Log.message(e.getMessage()); } finally { if

Get Album Art With Album Name Android

◇◆丶佛笑我妖孽 提交于 2019-12-17 17:48:31
问题 I want to display album art with album name in listview. But i am not getting the way to display album art. I have tried from cover art on android. Here is my Code : Cursor cursor = managedQuery(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, null, null, null, null); if (cursor == null) { //Query Failed , Handle error. } else if (!cursor.moveToFirst()) { //No media on the device. } else { int titleColumn = cursor.getColumnIndex(android.provider.MediaStore.Audio.Albums.ALBUM_ART); int id =

using ContentProviderClient vs ContentResolver to access content provider

≯℡__Kan透↙ 提交于 2019-12-17 17:24:50
问题 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 getContentResolver().acquireContentProviderClient(authority) . It seems to provide more or less the same methods available in the ContentResolver for accessing content from the provider. When should I use a ContentProviderClient instead of just using the ContentResolver directly

Android: Distinct and GroupBy in ContentResolver

梦想与她 提交于 2019-12-17 15:25:18
问题 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) 回答1: You can do nice hack when querying contentResolver, use: String selection = Models.SOMETHING + "=" + something + ") GROUP BY (" + Models.TYPE; 回答2: Since no one came to answer I'm just going to tell how I solved this. Basically I would create custom URI for

How to get whatsapp Contacts from Android Programmatically?

眉间皱痕 提交于 2019-12-17 10:19:28
问题 I have try to get whatsapp contact from phone and i get total Count of whatsapp contact but from RawContacts how to get whatsapp Number and name that i don't know. i have tried to find solution but can't get exact solution for that. Please help me. I put my code below. ContentResolver cr = context.getContentResolver(); Cursor c = cr.query( ContactsContract.RawContacts.CONTENT_URI, new String[] { ContactsContract.RawContacts.CONTACT_ID, ContactsContract.RawContacts.DISPLAY_NAME_PRIMARY },

How to get whatsapp Contacts from Android Programmatically?

你。 提交于 2019-12-17 10:18:33
问题 I have try to get whatsapp contact from phone and i get total Count of whatsapp contact but from RawContacts how to get whatsapp Number and name that i don't know. i have tried to find solution but can't get exact solution for that. Please help me. I put my code below. ContentResolver cr = context.getContentResolver(); Cursor c = cr.query( ContactsContract.RawContacts.CONTENT_URI, new String[] { ContactsContract.RawContacts.CONTACT_ID, ContactsContract.RawContacts.DISPLAY_NAME_PRIMARY },

Insertion of thousands of contact entries using applyBatch is slow

旧时模样 提交于 2019-12-17 06:27:31
问题 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 Account to hold the Contacts, so the user can select to see the contact in the Contacts view. But the insertion of the contacts is painfully slow. I insert the contacts using ContentResolver.applyBatch. I've tried with different sizes of the

android - Inserting, Updating, Deleting SMS using ContentResolver

一世执手 提交于 2019-12-16 18:06:08
问题 I've got a little problem, using the ContentResolver for inserting, updating and deleting a SMS on my Nexus 5. I searched a lot and tried everything which was suggested, but my smartphone still does not want to change it's entries in the SMS-database. My Code for deleting all SMS with a specific address looks like this: int i = a.getContentResolver().delete(Telephony.Sms.CONTENT_URI, Telephony.Sms.ADDRESS + "=?", new String[] { "0820800650" }); The return value is 0, for whatever condition I