Nobody
Nobody

Reputation: 678

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.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.

Upvotes: 1

Views: 1314

Answers (1)

devanshu_kaushik
devanshu_kaushik

Reputation: 969

It is probably because your app does not have root access. File permissions can be changed by root access only.

Upvotes: 1

Related Questions