I tried to get files in /sdcard/
folder, but it throws NullPointerException
Then I tried to get folders in /
path it returns
40
factory
usbdisk
sdcard
storage
config
cache
acct
vendor
d
etc
mnt
ueventd.tuna.rc
ueventd.rc
ueventd.goldfish.rc
system
sys
sepolicy
seapp_contexts
sbin
res
... and others
When I do this in 4.3 project it works well!
UPDATE
code in 4.4 which not work
File file = Environment.getExternalStorageDirectory();
File[] files = file.listFiles();
Debugger.info(files.length); // NullPointerExcepton
for(File f : files){
Debugger.info(f.getName());
}
id. mylist); myList = new ArrayList<String>(); File directory = Environment. getExternalStorageDirectory(); file = new File( directory + "/Test" ); File list[] = file. listFiles(); for( int i=0; i< list.
Head to Settings > Storage > Other and you'll have a full list of all the files and folders on your internal storage. (If you'd prefer this file manager be more easily accessible, the Marshmallow File Manager app will add it as an icon to your home screen.)
In Android Studio 3.5. 3, the Device File Explorer can be found in View -> Tool Windows. It can also be opened using the vertical tabs on the right-hand side of the main window.
The Android Developers site states (in the important behaviour changes in KitKat)
If your app reads from external storage...
Your app can not read shared files on the external storage when running on Android 4.4, unless your app has the READ_EXTERNAL_STORAGE permission. That is, files within the directory returned by getExternalStoragePublicDirectory() are no longer accessible without the permission. However, if you need to access only your app-specific directories, provided by getExternalFilesDir(), then you do not need the READ_EXTERNAL_STORAGE permission.
So make sure you give the above permision. Also, if you are using a device with multiple sd cards you may run in this issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With