How to set Last Modified File attribute using new SD-Card access API for Android 5.0?
Asked Answered
Z

0

6

Background:

Using: ACTION_OPEN_DOCUMENT_TREE + DocumentFile

More on: How to use the new SD card access API presented for Android 5.0 (Lollipop)?

I would like to ask:

I cannot find the way how to change file attributes. Is there any?

Particularly, I need to change Last Modified attribute - like the File Class method:

public boolean setLastModified(long time); 

I didn't find any subtitute in:

https://developer.android.com/reference/android/support/v4/provider/DocumentFile.html

or in one of the related classes like DocumentsContract, ...

The documentation for the new API is really almost useless, the API functions run desperately slow and the code rewriting for the new API is really messy work. I'm sorry to be so tough, but the Kitkat "EACCESS (Permission denied) feature" costs me a couple of years of my life and instead of a solution I will get this.

Edit:

It seems that the setLastModified(...) method does not work even with java.io.File Class (from Android version 4.4 - at least):

https://code.google.com/p/android/issues/detail?id=18624

So for example - if you have an archiver application and you want the true last modified time and not a time the files was extracted from an archive - sorry. A lot of synchronization tools become useless ...

Edit 2:

Android 5.1 (emulator): setLastModified(long time) method still does not work.

Edit 3:

Android 6.0 (emulator): setLastModified(long time) method still does not work.

Zabaglione answered 18/12, 2014 at 16:0 Comment(3)
Did you find any solution or workaround in the meantime?Ashleeashleigh
@Ashleeashleigh I'm afraid there is no workaround (not in Java). Maybe in native code, but I haven't tried it.Zabaglione
It seems, like the whole thing is missing quite a lot of things... You can't correctly copy files to sd card anymore nor can you directly use the ContentResolver CRUD options with the files URIs, but you need to update the media store as it is indexing the sd card... Thanks for the infoAshleeashleigh

© 2022 - 2024 — McMap. All rights reserved.