问题
I am using setReadOnly
method to make my app's directory stored on my SD card 'Read-only'. However this method when called is returning 'false' even though I have provided the app with android.permission.WRITE_EXTERNAL_STORAGE
permission in the manifest.
Here's my code :
is.close();
fos.close();
Decompress d = new Decompress(productDirectory + "/downloadedfile.zip", productDirectory + "/unzipped/");
d.unzip();
File zipfile = new File(productDirectory + "/downloadedfile.zip");
zipfile.delete();
productDirectory = new File(Environment.getExternalStorageDirectory().toString() + "/zipfiledemo");
boolean isWriteLocked = productDirectory.setReadOnly();
Log.v("Writing access locked",">>>>>>>>>>>>>>>>>>>" + isWriteLocked);
回答1:
You should define permission android.permission.MOUNT_UNMOUNT_FILESYSTEMS
in AndroidManifest.xml
, it means you can create file and delete file on the SDCard.
来源:https://stackoverflow.com/questions/7160182/setreadonly-not-working