I use this so that the user can select the file, after the selection I save only the file URI in general privileges. In the future, the user may open this file. Therefore, I have a 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 correctly understood the preservation of read permissions for later use), works only with API 19 and higher. What is equivalent to this below API 19? In general, the question is how to get persistnet permission in API`s below 19 in this template? Thank,
android android-contentresolver file-permissions permissions
michael May 24 '15 at 2:14 pm 2015-05-24 14:14
source share