0

[UPDATE] folder found in this path: /sdcard/myfolder and could download images into it but they don't show in the studio.

I'm trying to create a folder on SD Card to download files using code from this answer using a real device with Android 7

File folder = new File(Environment.getExternalStorageDirectory() + "/myfolder");
boolean success = true;
if (!folder.exists()) {
    success = folder.mkdirs();
    Toast.makeText(Main3Activity.this,"folder does not exist",Toast.LENGTH_SHORT).show();
}
if (success) {
    Toast.makeText(Main3Activity.this,"success",Toast.LENGTH_SHORT).show();
} else {
      Toast.makeText(Main3Activity.this,"error",Toast.LENGTH_SHORT).show();
}

AndroidManifest permissions

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

I get the request permission message and I grant permission then when I execute the code I get a success message but can't find the folder on SD Card at all so what's wrong with this code?

PHP User
  • 2,350
  • 6
  • 46
  • 87
  • 1
    First, that code works with [external storage](https://commonsware.com/blog/2017/11/14/storage-situation-external-storage.html), not [removable storage](https://commonsware.com/blog/2017/11/15/storage-situation-removable-storage.html). Second, depending on how you are checking for this directory, it might not show up until you put some file in it and get that file to be indexed. Use Android Studio's Device File Explorer or `adb shell` to see if the directory is created in the filesystem itself. – CommonsWare Dec 28 '18 at 19:45
  • found on inside sdcard directory but can't find it on the phone itself. i downloaded images in this folder but they don't appear in the studio. – PHP User Dec 28 '18 at 20:07

0 Answers0