1

I use this to let the user select file, after the selection I store in shared prefs only the URI of the file. In the future the user can open this file - So I have the URI and therefore it can be done

        final Intent intent = new Intent();
        if (Integer.valueOf(android.os.Build.VERSION.SDK_INT) >= 19) {
            intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
        }     
        else {
            intent.setAction(Intent.ACTION_GET_CONTENT);
        }        
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType("application/msword,application/pdf,text/plain");  //Text, DOC, PDF
        startActivityForResult(intent, READ_REQUEST_CODE);

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == READ_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
    //Get and Store the URI in shared prefs...
    final int takeFlags = data.getFlags()
                    & (Intent.FLAG_GRANT_READ_URI_PERMISSION
                    | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
    getContentResolver().takePersistableUriPermission(uri, takeFlags);
}

The last line of code (which if I understood correctly saving the read permission for later use) working only from API 19 and above. What is the equivalent for this below API 19? In general, the question is how to obtain in this pattern the persistnet permission in API`s below 19? Thanks,

michael
  • 3,835
  • 14
  • 53
  • 90

1 Answers1

1

What is the equivalent for this below API 19?

There is none, short of making a copy of the content as a local file within your own app.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491