Search code examples
androidstorage-access-framework

android is it possible to writeprotect a plain/text file I have created using the StorageAccessFramework?


I'm working on a text editor and would like to be able to write protect a file. Is this possible? I can get its permissions from its URI using a cursor and (COLUMN_FLAGS and FLAG_SUPPORTS_WRITE) but I can't find a way to change its permissions.

I also figured out a way to get the physical file location on the SD card using the ParcelFileDescriptor's proc fd but file.setWriteable(false, true) doesn't work.

Thanks
Steve S.


Solution

  • Is this possible?

    No, sorry.

    I can get its permissions from its URI using a cursor and (COLUMN_FLAGS and FLAG_SUPPORTS_WRITE) but I can't find a way to change its permissions.

    Those are not really "permissions". FLAG_SUPPORTS_WRITE simply means that the content is read-only. For example, the "Media" provider declares everything it serves as read-only.

    I also figured out a way to get the physical file location on the SD card using the ParcelFileDescriptor's proc fd but file.setWriteable(false, true) doesn't work.

    Correct, that's not supported.