-
-
Notifications
You must be signed in to change notification settings - Fork 10
feat: On Android I can't select files on SD card - I see only Photos and Google drive #60
Comments
Unfortunately, I do not have an Android device with SD card. I guess that the permissions are missing. Add the following permissions to your <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> (More info here) Use the import { Filesystem } from '@capacitor/filesystem';
const pickFiles = async () => {
// 1. Request permissions
await Filesystem.requestPermissions();
// 2. Pick files
const result = await FilePicker.pickFiles();
const file = result.files[0];
alert('Selected file is' +
JSON.stringify(file) +
' ' + JSON.stringify(result));
return result
}; Please let me know if this helps. |
Hi, I have those permissions set. (Running inside emulator) You can find the code and a repro here: https://github.com/ieugen/organice/blob/ddf41a3451784473952e894d53b4b4e17004dee2/src/components/SyncServiceSignIn/index.js#L175 . For build instructions see https://github.com/ieugen/organice/tree/android-local-fs#native-app-on-android . I also checked the application permissions and they are present (I got asked for them). There is also the fact that StorageClient app for https://github.com/android/storage-samples/tree/main/StorageClient . |
ok, so I talked with a friend that does Android development and we discovered that the difference is caused by this:
This API is old for Android less then 4.3 https://developer.android.com/guide/topics/providers/document-provider#client
Should be updated to
And an option added to support directories:
List of API's to access storage: https://developer.android.com/training/data-storage . |
The Storage Access Framework API does not need extra permissions (as documented). |
Thanks for your research. I will take a look. |
I have had a look at it and think that
(Source) However, I was able to find another fix (see #67).
|
Thanks. |
Is your feature request related to a problem? Please describe:
I would like to be able to pick files (a directory, see capawesome-team/capacitor-plugins#16 )
from my SD card .
Right now I can't see my SD card with the sample code I found on the README.
Is there a way to do that?
This is the code I use:
I am getting this in my emulator.
The text was updated successfully, but these errors were encountered: