Zvi
Zvi

Reputation: 2424

No sdcard folder on my emulator

I tried writing to the sdcard folder using the emulator, with no success, although few weeks ago it worked. I get the sdcard folder, in my app, using Environment.getExternalStorageDirectory(). So I opened Android Device Monitor and I see no sdcard folder. I see a file with the name sdcard in my root folder and one in the mnt/ folder. What is wrong?

The problem I am facing is not only that I do not see the sdcard but rather that I can not create a folder in it. I thought that if I solve the problem of not seeing it it will solve my main issue. Here is my code where isPresesnt returns false.

I also made sure that I have permission to write to the external storage.

It seems that the problem exists only with the emulator - I just tested it on my phone and it worked fine.

I also noticed that if I connect my phone to my computer while the emulator is opened, I do see the sdcard folder in the Android Device Monitor, but I do not know to which device it belongs to.

my code

    File path = new File(Environment.getExternalStorageDirectory() + "/Documents");
    boolean isPresent = true;
    if (!path.exists()) {
        isPresent = path.mkdir();
    }

MANIFEST

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

permission code

            perms.put(android.Manifest.permission.WRITE_EXTERNAL_STORAGE, PackageManager.PERMISSION_GRANTED);

Upvotes: 0

Views: 678

Answers (1)

Bui Quang Huy
Bui Quang Huy

Reputation: 1794

Actually we cannot see SD card folder on our emulator, but it still exist in mnt/sdcard like what you mention above. If you want to see it, just import an image to that folder and it with appear in Gallery with folder name sdcard.

Upvotes: 1

Related Questions