Skip to content Skip to sidebar Skip to footer

Environment.getexternalstoragedirectory() On The Emulator

I want to read and write images to the external storage in my app. From what I read the following is the correct way to get a handle on the directory. File externalStorageDir = En

Solution 1:

You might want to make sure you have external storage enabled:

In Eclipse, go to Window > Android SDK and AVD Manager. Select the appropriate AVD and then click Edit. Window - Android SDK and AVD Manager

Make sure you have SD card support enabled. If you do not, click the "New" button and select the "SD Card Support" option.

Edit screen

EDIT: Also need to add

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

to the manifest.

Solution 2:

By default, the emulator will be launched without a sd card. You should create a sd card image first by using the mksdcard command in console. See SDK document:https://developer.android.com/studio/command-line/mksdcard.html

Hence, in the console, type the command to launch an emulator with that sd card:

    emulator -avd <emulatorname> -sdcard <sdcardimagename>

For better performance, I strongly suggest you debug your app via a real device.

Post a Comment for "Environment.getexternalstoragedirectory() On The Emulator"