in Education by
In Android Q the field MediaStore.Files.FileColumns.DATA has been deprecated, and may be Null or apps have no rights to read it when targeting such OS version, so will be preferable to work using only a file’s content Uri. Since the MediaScannerConnection only accepts file paths, I found that for Android Q this is no longer an option. What would be the way to force an automatic MediaStore update/re-scan of a single file, without knowing its real path and using only its Uri? The intention is not to even try to find the real path and rely only in the Uri. Consider that the Uri to force the update is a media content Uri (not a SAF Uri). Example: content://media/external/images/media/123 The solution must not be to re-scan the entire storage or un-mount / mount the storage again, as this will have a high performance hit in our workflow and will make it completely unusable. And because the intention is to use only the Uri, then to avoid forcing a scan of any specific directory of files, which would also have an impact if it contains lots of files, and implies that a real directory path must be resolved from the Uri, which is not an option. UPDATE: We have tried with unsuccessful results the ContentResolver.refresh method introduced in Android O, yet this method doesn't do any refresh at all when it comes to a media content Uri in a format such as: content://media/external/images/media/123 final ContentResolver resolver = context.getContentResolver(); resolver.refresh(uri, null, null); JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I'm currently also trying to redesign my app to use just URIs rather than using all of the hacky solutions to convert them to filepaths (like guessing the path based on the uri authority, etc.) Previously, I used MediaScannerConnection.scanFile(...), which worked without a flaw, but as you've probably already tried, this doesn't work with URIs. I am finding success by manually updating the MediaStore URI with my new data like this: public void updateMediaStore(final Uri content, final String title) { final ContentValues values = new ContentValues(); values.put(MediaStore.Audio.AudioColumns.TITLE, title); // ... the rest of your data cr.update(res, values, null, null); } Still, it seems like an oversight to not provide a way to rescan a specific file. For example, if this URI comes from somewhere else, such as on an sdcard via SAF, you will have to first search for it in the MediaStore before updating it.

Related questions

0 votes
    The __________ requires that each transaction Ti executes in two or three different phases in its lifetime ... topic in section Concurrency Control of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    Explain How to change the URI (URL) for a remote Git repository?...
asked Jan 7, 2021 in Technology by JackTerrance
0 votes
    I writing a function in my form that require user to upload a file, but doesn't necessary have to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    How do I redirect to another route without a hard refresh? I created an ionic / angular app for ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    Which of the following tag represents a piece of content that is only slightly related to the rest of the page in HTML5? A - section B - article C - aside D - header...
asked Dec 1, 2020 in Technology by JackTerrance
0 votes
    I'm currently using Cloud Firestore as my backend for a mobile app. I've got basic payments working ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    What are the best practices to create a standard URI for a web service?...
asked Nov 7, 2020 in Technology by JackTerrance
0 votes
    When I attempt to load data into BigQuery from Google Cloud Storage it asks for the Google Cloud Storage URI ... Developers Console? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    Which of these is a mechanism for naming and visibility control of a class and its content? (a) Object (b) ... & Packages of Java Select the correct answer from above options...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    What's the standard way of updating a QTableView when its database (MySQL) was changed (outside of the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I have a column array with the following values in my sheet: 11, 15, 5, 7, 2. I want to ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
...