Ashishkumar Singh
Ashishkumar Singh

Reputation: 3600

root.listFiles() return null

I created an activity which will recursively scan all the files in a particular directory. For this, I used the File object return by

'Environment.getExternalStorageDirectory()' 

as the starting point.

Now the issue is, on calling files.listFiles() on this object, I am getting a null value. I check the return value of 'Environment.getExternalStorageDirectory()' and it is '/storage/emulated/0'. I have also checked and made sure that there is a file inside this directory. But I am unable to understand why it is returning a null value.

I am using an inbuild android emulator for testing

Can someone please help me here

Upvotes: 1

Views: 761

Answers (1)

melonT
melonT

Reputation: 427

This may solves the issue:

https://developer.android.com/training/permissions/requesting.html

If the device is running Android 6.0 or higher, and your app's target SDK is 23 or higher: The app has to list the permissions in the manifest, and it must request each dangerous permission it needs while the app is running. The user can grant or deny each permission, and the app can continue to run with limited capabilities even if the user denies a permission request.

Upvotes: 1

Related Questions