[mono-android] System.IO.File.GetAttributes returns always ReadOnly
Jonathan Pryor
jonp at xamarin.com
Fri Feb 17 15:01:31 UTC 2012
On Feb 17, 2012, at 7:12 AM, tsukrov wrote:
> Any hope for the bug to be fixed before 1 March?
Probably not. :-)
> Any way to get the same behaviour with Java classes? I need to get/set ReadOnly flag.
>
> setWritable(false, false) doesn't do the trick.
> canWrite() is still true.
>
> Am I misunderstanding something completely?
...
> We have a demo file, that should not be edited by the users - we would like to make it readOnly.
The problem here is that what you want is not supported by Android external storage:
http://developer.android.com/guide/topics/data/data-storage.html#filesExternal
"Files saved to the external storage are world-readable and can be modified by the user when they enable USB mass storage to transfer files on a computer."
This is By Design, and contrary to your desire that the file be read-only. There is no way to make a file on external storage read-only.
If you really want it read-only, don't put it on external storage. Keep it private to your app (e.g. /data/data/PACKAGE.NAME/files/...), where external storage doesn't have access.
- Jon
More information about the Monodroid
mailing list