Java – How to emulate a real external sd (update: removable storage) card in Android Emulator

How to emulate a real external sd (update: removable storage) card in Android Emulator… here is a solution to the problem.

How to emulate a real external sd (update: removable storage) card in Android Emulator

I tried to emulate an external SD card just like in a real device.

In real devices, external SD cards are not writable unless you use the new Storage Access Framework (APIs 21 and 22).

When I add sdcard with file or size….

enter image description here

I

always get a writable SD card, which is not true on real devices (I guess). I can create the folder “CreateFolder” (I know, I shouldn’t use direct access, but this is just to test if I have write permissions):

        String spathWriteTest="/storage/sdcard/";
        new File(spathWriteTest + "createFolder").mkdir();

enter image description here

Any ideas, how to emulate a real external SD card?

Solution

When you set up an AVD, it refers to “SD card”, which actually refers to external storage, not removable storage The emulator does not emulate removable storage. You can see if Genymotion emulates removable storage.

Related Problems and Solutions