android-contentresolver

How to retrieve all contacts details from Content provider with single query?

痞子三分冷 提交于 2021-01-06 03:28:53
问题 I need to read the contacts from device. The fields I required are ID , Display Name , Phone Number (All types) Email id (All types) and 'photo'. For this right now I am doing like this. 1 : First I am reading all the id s from ContactsContract.Contacts.CONTENT_URI; as shown below Uri contactsUri = ContactsContract.Contacts.CONTENT_URI; // Querying the table ContactsContract.Contacts to retrieve all the contacts String[] projection = {ID}; Cursor contactsCursor = mContentResolver.query

How to retrieve all contacts details from Content provider with single query?

◇◆丶佛笑我妖孽 提交于 2021-01-06 03:27:30
问题 I need to read the contacts from device. The fields I required are ID , Display Name , Phone Number (All types) Email id (All types) and 'photo'. For this right now I am doing like this. 1 : First I am reading all the id s from ContactsContract.Contacts.CONTENT_URI; as shown below Uri contactsUri = ContactsContract.Contacts.CONTENT_URI; // Querying the table ContactsContract.Contacts to retrieve all the contacts String[] projection = {ID}; Cursor contactsCursor = mContentResolver.query

ContentResolver query method cannot be used, NoSuchMethodError

送分小仙女□ 提交于 2020-08-18 21:02:53
问题 I am creating an app that reads the phone contacts of your phone. However, for reasons that I don't know, I have a problem using the query method because of the api version that I used. It says that Call requires API level 26 (current min is 16): android.content.ContentResolver#query . Here's my code I used in the oncreate method. public void searchContacts() { ContentResolver contentResolver = getContentResolver(); Cursor cursor = contentResolver.query(ContactsContract.Contacts.CONTENT_URI,

How to get the path of a video which is selected from gallery on android 10

北城以北 提交于 2020-08-10 23:47:57
问题 I tried lot of snippets. This is what I'm using now. I know that MediaStore.Video.Media.DATA is deprecated.somehow this method is working on android 10 as well but sometimes it throws android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 public static String getvideoPath(Context context, Uri uri) { try { Cursor cursor = context.getContentResolver().query(uri, null, null, null, null); cursor.moveToFirst(); String document_id = cursor.getString(0); LogMessage.v(

ContentResolver Query on DocumentContract Lists all files disregarding selection

Deadly 提交于 2020-08-09 07:14:53
问题 Im trying to get all files from a directory which have a certain MIME Type - i want all images. I had used some example code where you use MediaStore as URI but it later turned out difficult to filter that for the chosen directory because the URIs returned in the resultset have a different format than the URI i supplied... So instead i found this example code https://github.com/googlesamples/android-DirectorySelection it queries the DocumentContract on the selected subtree and now needs