How to Set file permissions- Android
I have a doc file on sdcard.
I want to open it in read-only mode. Also I don't want the document viewer to save the file.
The intent to open the file is as follows:
Intent intent = new Intent();
intent.setAction(android.content.开发者_JAVA技巧Intent.ACTION_VIEW);
File file = new File("/sdcard/test.doc");
file.setReadOnly();
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION );
intent.setDataAndType(Uri.fromFile(file), "application/msword");
startActivity(intent);
But when the file opens in quickOffice, the file is still editable.
Please suggest how should I make the file ready-only to any document viewer and how should I prevent file from saving.
It is probably because your app does not have root access. File permissions can be changed by root access only.
精彩评论