android-contentresolver

Android 10: fetch the gallery via MediaStore with location information

二次信任 提交于 2020-07-04 13:50:30
问题 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 fetch medias one by one, but what about when we query the ContentResolver for the whole gallery? See this sample: String[] projection = { MediaStore.Files.FileColumns._ID, MediaStore.Files.FileColumns.DATA, MediaStore.Files.FileColumns.MEDIA_TYPE,

Media scanner for secondary storage on Android Q

狂风中的少年 提交于 2020-07-04 06:45:29
问题 With the newer Android Q many things changed, especially with scoped storage and gradual deprecation of file:/// URIs. The problem is the lack of documentation on how to handle media files correctly on Android Q devices. I have a media file (audio) management application and I could not find yet a reliable way to tell to the OS that I performed a change to a file so that it can update its MediaStore record. Option #1: MediaScannerService MediaScannerConnection.scanFile(context, new String[]{

Android Calendar Provider does not return latest data

爷,独闯天下 提交于 2020-05-16 22:39:07
问题 I am using the following code: String selection = "((dtstart >= " + now + ") AND (dtend <= " + endTime.getTimeInMillis() + "))"; Cursor cursor = context.getContentResolver() .query(Uri.*parse*("content://com.android.calendar/events"), *PROJECTION*, selection,null, null); And I notice that once I add/remove an Event to Google Calendar app on the device and run the above code immediately, occasionally I do not get the latest dataset from the Cursor . I have to manually refresh the Google

Replacement for “GROUP BY” in ContentResolver query in Android Q ( Android 10, API 29 changes)

 ̄綄美尐妖づ 提交于 2020-05-16 03:59:46
问题 I'm upgrading some legacy to target Android Q, and of course this code stop working: String[] PROJECTION_BUCKET = {MediaStore.Images.ImageColumns.BUCKET_ID, MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME, MediaStore.Images.ImageColumns.DATE_TAKEN, MediaStore.Images.ImageColumns.DATA, "COUNT(" + MediaStore.Images.ImageColumns._ID + ") AS COUNT", MediaStore.Files.FileColumns.MEDIA_TYPE, MediaStore.MediaColumns._ID}; String BUCKET_GROUP_BY = " 1) and " + BUCKET_WHERE.toString() + " GROUP BY

What is difference between contentprovider and contentResolver in android

旧城冷巷雨未停 提交于 2020-02-16 18:49:51
问题 What is the difference between ContentProviders and ContentResolver ? I do not want for the SQLite database. I am developing an application for media. 回答1: I found some explanation here. In summary Content Resolver resolves a URI to a specific Content provider . Content Provider provides an interface to query content. The way to query a content provider is contentResolverInstance.query(URI,.....) 回答2: ContentProviders are used to abstract the database from other parts and acts as an interface

What is difference between contentprovider and contentResolver in android

十年热恋 提交于 2020-02-16 18:48:55
问题 What is the difference between ContentProviders and ContentResolver ? I do not want for the SQLite database. I am developing an application for media. 回答1: I found some explanation here. In summary Content Resolver resolves a URI to a specific Content provider . Content Provider provides an interface to query content. The way to query a content provider is contentResolverInstance.query(URI,.....) 回答2: ContentProviders are used to abstract the database from other parts and acts as an interface

Create/Copy File in Android Q using MediaStore

自古美人都是妖i 提交于 2020-02-06 07:31:11
问题 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 move to Download Folder or some directory which I can create in Internal storage and then move their. I searched and found modified below code but missing some thing to make it workable. Can some one help. ContentResolver contentResolver =

How can I get MediaMetaData like Album, Track, Titel, Albumart, etc. from MediaStore in Android 10

此生再无相见时 提交于 2020-01-25 10:14:06
问题 I struggled for a long time to fetch album, track, duration, album art from audiofiles using Android 10 mediaStore . What I did so far: Open an Intent an fetch the Audio-Folder: Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); startActivityForResult(Intent.createChooser(intent, "Choose directory"), PICK_AUDIO_REQUEST); Then

Contact fetching takes too much time

落爺英雄遲暮 提交于 2020-01-23 20:44:55
问题 In my code the contact fetching takes too much time to fetch the contacts and show in the application. Please guide me where i am wrong and what should i correct in order to make execution time fast. Here is my code. ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null ); String phone = null; List<String> phonenumber = new ArrayList<String>(); String emailContact = null; String emailType = null; String image_uri = "";

Android ContentResolver query sometimes not starting ContentProvider process

瘦欲@ 提交于 2020-01-13 03:24:28
问题 I have been implementing my own custom content provider in an app A and want to query its database from a separate app B that calls ContentResolver.query(...) using the appropriate custom URI defined in A. All goes well when A has been running just before I launch B (thus A's process still running in the background). However when I kill A's process, then B fails to query A's database! I thought querying a content provider would automatically start its process so the data can be retrieved. Am