I'm creating an application and i need to create and show to the user some folders. For testing i'm using my nexus 5 (android marshmallow). I'm using this code:
File imageRoot = new File(getFilesDir(), "MyDir");
imageRoot.mkdir();
and after:
MediaScannerConnection.scanFile(MainActivity.this, new String[] imageRoot.toString()}, null, new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(String path, Uri uri) {
Log.d("path","path is" + path);
}
});
In this case mkdir return true, but MediaScannerConnection doesn't show me files (or folder)in the internal storage.
Log.d show this path:
/data/user/0/com.example.federico.savefolder/files/MyDir/
but i don't see anything when i search in the folders.
I insert the permissions:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
I try this solution and creating a folder in the ExternalStorageDirectory (the path should be: "/storage/emulated/0") but doesn't work.
Any Solutions? thanks in advance.