I'm trying to update the last modified date of a document/file but I'm getting an "UnsupportedOperationException: Update not supported"
Steps to reproduce:
- Picking a document tree
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
startActivityForResult(intent, 1972);
- On Activity Result creating a new document inside the picked directory:
Uri treeUri = resultData.getData();
String treeDocumentId = DocumentsContract.getTreeDocumentId(treeUri);
treeUri = DocumentsContract.buildDocumentUriUsingTree(treeUri, treeDocumentId);
Uri uri = DocumentsContract.createDocument(getContentResolver(), treeUri, "text/plain", "test.txt");
- Trying to update the last modified date of the document/file
ContentValues values = new ContentValues();
values.put(DocumentsContract.Document.COLUMN_LAST_MODIFIED, 1592143965000L);
getContentResolver().update(uri, values, null, null);
Tried as well to insert but the result is always the same:
Caused by: java.lang.UnsupportedOperationException: Update not supported
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
at android.content.ContentProviderProxy.update(ContentProviderNative.java:578)
at android.content.ContentResolver.update(ContentResolver.java:2009)
Did anyone experience the same issue respective found a solution for this problem?