I am attempting to write a readonly file to my SD card. I need to do this as a two step process.
public void method1(String cacheFilename) {
File cacheDir = mContext.getExternalCacheDir();
File cachedFileOnDisk = new File(cacheDir, cacheFilename);
FileOutputStream fileStream = new FileOutputStream(cachedFile);
fileStream.write(...)
fileStream.flush();
fileStream.close();
}
public void method2(String cacheFilename) {
File cacheDir = mContext.getExternalCacheDir();
File cachedFileOnDisk = new File(cacheDir, cacheFilename);
if(!cachedFileOnDisk.setReadOnly()) {
throw new IllegalStateException();
}
Where method1 is invoked and then at a subsequent stage method2.
The cachedFileOnDisk.setReadOnly() call returns a false to me and I am unable to set the file to read only.
Is there a way I could write readonly files to my SD card?