user1083266
user1083266

Reputation: 1801

While creating sub directory in sd card on emulator getting permissions denied error

i am trying to create sd card on emulator. in devtools in terminal emulator i gave cmds $cd sdcard $mkdir pictures but is showing error mkdir failed for pictures,permissions denied. please help me how to create sdcard on emulator

Upvotes: 0

Views: 3430

Answers (4)

sandalone
sandalone

Reputation: 41749

All issues with permission come from using the default sdcard image. So simply create a new sdcard image.

To do this, open AVD Manager in Android Studio, click on "Show Advanced Settings" on the bottom of the screen and then create a new sdcard image. Both options are marked on the image below.

After this you will be able to use console to create images, push files, and other tasks.

Upvotes: 0

user1217690
user1217690

Reputation:

if you are using Eclipce then follow these steps

goto Window->AVD manager->select the AVD for which you want to create the sdcard then click edit on sd card panel give the size->edit AVD

to show the image after upload u have to run

Menu-->Dev Tools-->Media Scanner

source

is't this simple?

Upvotes: 2

Rakshi
Rakshi

Reputation: 6856

you have to set the permission in manifest before you do so.

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

Include this to create a directory.

String extStorageDirectory = "/mnt/sdcard/Foldername/";
File myNewFolder = new File(extStorageDirectory); 
if ( !myNewFolder.exists() ) 
   myNewFolder.mkdir();

Upvotes: 0

Rakshi
Rakshi

Reputation: 6856

This method can be used to copy a file from source to destination. public void copy(File src, File dst) throws IOException { InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dst);

    // Transfer bytes from in to out
    byte[] buf = new byte[1024];
    int len;
    while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
    }
    in.close();
    out.close();
}

Upvotes: 0

Related Questions