Android open InputStream from relative uri to ACTION_OPEN_DOCUMENT?
up vote
0
down vote
favorite
I'am trying to open multiple files relative to a json configuration file in android 4.4 (api level 19),
I used
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType({mime});
this.startActivityForResult(intent, {code});
to let the user find te configuration file, and from there open multiple files that I know the path from the config file.
But i get
Caused by: java.lang.SecurityException:
Permission Denial: reading com.android.providers.downloads.DownloadStorageProvider
uri content://com.android.providers.downloads.documents/document/raw:/storage/emulated/0/Download/{relative file}
requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
I dont want to use user interfaces to open the other files, so I tried adding the following permissions without getting any results
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS "/>
I would rather have the files separated and not in a blob or a zip file
android relative-path permission-denied android-contentresolver storage-access-framework
add a comment |
up vote
0
down vote
favorite
I'am trying to open multiple files relative to a json configuration file in android 4.4 (api level 19),
I used
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType({mime});
this.startActivityForResult(intent, {code});
to let the user find te configuration file, and from there open multiple files that I know the path from the config file.
But i get
Caused by: java.lang.SecurityException:
Permission Denial: reading com.android.providers.downloads.DownloadStorageProvider
uri content://com.android.providers.downloads.documents/document/raw:/storage/emulated/0/Download/{relative file}
requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
I dont want to use user interfaces to open the other files, so I tried adding the following permissions without getting any results
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS "/>
I would rather have the files separated and not in a blob or a zip file
android relative-path permission-denied android-contentresolver storage-access-framework
have you put the runtime permission for READ_EXTERNAL_STORAGE and MANAGE_DOCUMENTS?
– jay shah
Nov 11 at 5:29
I just tried that, I can get READ_EXTERNAL_STORAGE, but not MANAGE_DOCUMENTS, and still get Permission denial. im using minSdkVersion 19, so tried with ActivityCompat.requestPermissions
– Juan
Nov 11 at 6:16
"I'am trying to open multiple files" -- your code is not really related to opening files. If you need to limit the user to files on the filesystem that your app has the ability to access directly, use a file chooser library, not a systemIntent
likeACTION_OPEN_DOCUMENT
.
– CommonsWare
Nov 11 at 12:08
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'am trying to open multiple files relative to a json configuration file in android 4.4 (api level 19),
I used
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType({mime});
this.startActivityForResult(intent, {code});
to let the user find te configuration file, and from there open multiple files that I know the path from the config file.
But i get
Caused by: java.lang.SecurityException:
Permission Denial: reading com.android.providers.downloads.DownloadStorageProvider
uri content://com.android.providers.downloads.documents/document/raw:/storage/emulated/0/Download/{relative file}
requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
I dont want to use user interfaces to open the other files, so I tried adding the following permissions without getting any results
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS "/>
I would rather have the files separated and not in a blob or a zip file
android relative-path permission-denied android-contentresolver storage-access-framework
I'am trying to open multiple files relative to a json configuration file in android 4.4 (api level 19),
I used
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType({mime});
this.startActivityForResult(intent, {code});
to let the user find te configuration file, and from there open multiple files that I know the path from the config file.
But i get
Caused by: java.lang.SecurityException:
Permission Denial: reading com.android.providers.downloads.DownloadStorageProvider
uri content://com.android.providers.downloads.documents/document/raw:/storage/emulated/0/Download/{relative file}
requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
I dont want to use user interfaces to open the other files, so I tried adding the following permissions without getting any results
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS "/>
I would rather have the files separated and not in a blob or a zip file
android relative-path permission-denied android-contentresolver storage-access-framework
android relative-path permission-denied android-contentresolver storage-access-framework
edited Nov 11 at 6:28
asked Nov 11 at 5:13
Juan
525
525
have you put the runtime permission for READ_EXTERNAL_STORAGE and MANAGE_DOCUMENTS?
– jay shah
Nov 11 at 5:29
I just tried that, I can get READ_EXTERNAL_STORAGE, but not MANAGE_DOCUMENTS, and still get Permission denial. im using minSdkVersion 19, so tried with ActivityCompat.requestPermissions
– Juan
Nov 11 at 6:16
"I'am trying to open multiple files" -- your code is not really related to opening files. If you need to limit the user to files on the filesystem that your app has the ability to access directly, use a file chooser library, not a systemIntent
likeACTION_OPEN_DOCUMENT
.
– CommonsWare
Nov 11 at 12:08
add a comment |
have you put the runtime permission for READ_EXTERNAL_STORAGE and MANAGE_DOCUMENTS?
– jay shah
Nov 11 at 5:29
I just tried that, I can get READ_EXTERNAL_STORAGE, but not MANAGE_DOCUMENTS, and still get Permission denial. im using minSdkVersion 19, so tried with ActivityCompat.requestPermissions
– Juan
Nov 11 at 6:16
"I'am trying to open multiple files" -- your code is not really related to opening files. If you need to limit the user to files on the filesystem that your app has the ability to access directly, use a file chooser library, not a systemIntent
likeACTION_OPEN_DOCUMENT
.
– CommonsWare
Nov 11 at 12:08
have you put the runtime permission for READ_EXTERNAL_STORAGE and MANAGE_DOCUMENTS?
– jay shah
Nov 11 at 5:29
have you put the runtime permission for READ_EXTERNAL_STORAGE and MANAGE_DOCUMENTS?
– jay shah
Nov 11 at 5:29
I just tried that, I can get READ_EXTERNAL_STORAGE, but not MANAGE_DOCUMENTS, and still get Permission denial. im using minSdkVersion 19, so tried with ActivityCompat.requestPermissions
– Juan
Nov 11 at 6:16
I just tried that, I can get READ_EXTERNAL_STORAGE, but not MANAGE_DOCUMENTS, and still get Permission denial. im using minSdkVersion 19, so tried with ActivityCompat.requestPermissions
– Juan
Nov 11 at 6:16
"I'am trying to open multiple files" -- your code is not really related to opening files. If you need to limit the user to files on the filesystem that your app has the ability to access directly, use a file chooser library, not a system
Intent
like ACTION_OPEN_DOCUMENT
.– CommonsWare
Nov 11 at 12:08
"I'am trying to open multiple files" -- your code is not really related to opening files. If you need to limit the user to files on the filesystem that your app has the ability to access directly, use a file chooser library, not a system
Intent
like ACTION_OPEN_DOCUMENT
.– CommonsWare
Nov 11 at 12:08
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
ACTION_OPEN_DOCUMENT
only gives you access to exactly the file (or files, if you use EXTRA_ALLOW_MULTIPLE
) that the user selects.
You can use ACTION_OPEN_DOCUMENT_TREE to allow the user to select a folder - you'll then get access to all files in that folder (and their subfolders).
ACTION_OPEN_DOCUMENT_TREE was added in API level 21, Forgot to specify, but I'm using minSdkVersion 19, so I cant use that, I think I'll just use zip files :'(
– Juan
Nov 11 at 6:25
1
Correct, there's no equivalent pre-API 21.
– ianhanniballake
Nov 11 at 7:17
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
ACTION_OPEN_DOCUMENT
only gives you access to exactly the file (or files, if you use EXTRA_ALLOW_MULTIPLE
) that the user selects.
You can use ACTION_OPEN_DOCUMENT_TREE to allow the user to select a folder - you'll then get access to all files in that folder (and their subfolders).
ACTION_OPEN_DOCUMENT_TREE was added in API level 21, Forgot to specify, but I'm using minSdkVersion 19, so I cant use that, I think I'll just use zip files :'(
– Juan
Nov 11 at 6:25
1
Correct, there's no equivalent pre-API 21.
– ianhanniballake
Nov 11 at 7:17
add a comment |
up vote
2
down vote
accepted
ACTION_OPEN_DOCUMENT
only gives you access to exactly the file (or files, if you use EXTRA_ALLOW_MULTIPLE
) that the user selects.
You can use ACTION_OPEN_DOCUMENT_TREE to allow the user to select a folder - you'll then get access to all files in that folder (and their subfolders).
ACTION_OPEN_DOCUMENT_TREE was added in API level 21, Forgot to specify, but I'm using minSdkVersion 19, so I cant use that, I think I'll just use zip files :'(
– Juan
Nov 11 at 6:25
1
Correct, there's no equivalent pre-API 21.
– ianhanniballake
Nov 11 at 7:17
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
ACTION_OPEN_DOCUMENT
only gives you access to exactly the file (or files, if you use EXTRA_ALLOW_MULTIPLE
) that the user selects.
You can use ACTION_OPEN_DOCUMENT_TREE to allow the user to select a folder - you'll then get access to all files in that folder (and their subfolders).
ACTION_OPEN_DOCUMENT
only gives you access to exactly the file (or files, if you use EXTRA_ALLOW_MULTIPLE
) that the user selects.
You can use ACTION_OPEN_DOCUMENT_TREE to allow the user to select a folder - you'll then get access to all files in that folder (and their subfolders).
answered Nov 11 at 5:52
ianhanniballake
101k14210222
101k14210222
ACTION_OPEN_DOCUMENT_TREE was added in API level 21, Forgot to specify, but I'm using minSdkVersion 19, so I cant use that, I think I'll just use zip files :'(
– Juan
Nov 11 at 6:25
1
Correct, there's no equivalent pre-API 21.
– ianhanniballake
Nov 11 at 7:17
add a comment |
ACTION_OPEN_DOCUMENT_TREE was added in API level 21, Forgot to specify, but I'm using minSdkVersion 19, so I cant use that, I think I'll just use zip files :'(
– Juan
Nov 11 at 6:25
1
Correct, there's no equivalent pre-API 21.
– ianhanniballake
Nov 11 at 7:17
ACTION_OPEN_DOCUMENT_TREE was added in API level 21, Forgot to specify, but I'm using minSdkVersion 19, so I cant use that, I think I'll just use zip files :'(
– Juan
Nov 11 at 6:25
ACTION_OPEN_DOCUMENT_TREE was added in API level 21, Forgot to specify, but I'm using minSdkVersion 19, so I cant use that, I think I'll just use zip files :'(
– Juan
Nov 11 at 6:25
1
1
Correct, there's no equivalent pre-API 21.
– ianhanniballake
Nov 11 at 7:17
Correct, there's no equivalent pre-API 21.
– ianhanniballake
Nov 11 at 7:17
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246026%2fandroid-open-inputstream-from-relative-uri-to-action-open-document%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
have you put the runtime permission for READ_EXTERNAL_STORAGE and MANAGE_DOCUMENTS?
– jay shah
Nov 11 at 5:29
I just tried that, I can get READ_EXTERNAL_STORAGE, but not MANAGE_DOCUMENTS, and still get Permission denial. im using minSdkVersion 19, so tried with ActivityCompat.requestPermissions
– Juan
Nov 11 at 6:16
"I'am trying to open multiple files" -- your code is not really related to opening files. If you need to limit the user to files on the filesystem that your app has the ability to access directly, use a file chooser library, not a system
Intent
likeACTION_OPEN_DOCUMENT
.– CommonsWare
Nov 11 at 12:08