简体   繁体   中英

Android emulator sdcard permissions

I'm using eclipse and trying to get the android emulator to let me write to the sdcard.

when I install the app on my phone it prompts to accept the permission required... and the program works. When I try using the emulator to test the app I don't get prompted and using the program results in permission denied.

I've tried recreating my avd... and have the sdcard size set to 4Gb. Obviously I have the uses permission line in the AndroidManifest.xml... and here it is:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="j**.B********.App"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="10" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application android:icon="@drawable/icon" android:label="@string/app_name" android:permission="android.permission.WRITE_EXTERNAL_STORAGE">
        <activity android:name=".NotesActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>

So how do I get the emulator to give me the permission to write to the sdcard? What I've done works on the phone... so why not in the emulator?

Just now in the dev tools terminal in the emulator I tried to navigate to the sdcard... permission denied.

Looking at permissions in eclipse DDMS perspective and they are d---------

Edit: I got it to work.

I had to manually start the emulator from the avd manager. Letting eclipse start the emulator when you hit run seems to short circuit something.

Open the AVD manager, select the appropriate emulator, and choose Edit from right panel.

Then on the hardware option, you will see many properties, now, click the New button, and choose SD card support , click Ok .

Now you can use your SD-Card within the emulator.

In Android 6, and Emulator, We need to grand permission manual by Setting > Apps Chose App that you want to grant permission then grant permission like this:

在此处输入图像描述

Share for someone face this issue (I use android studio)

I'm getting this problem A LOT with the Gingerbread emulator... for some reason the emulator simply doesn't permit access eventhough the manifest permission is in place.

Solution:

access android shell (ie adb shell) and type in:

mount -o remount,rw /sdcard

Just a guess-- but perhaps you've configured the emulator with 0 external storage?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM