Android emulator sdcard permissions

て烟熏妆下的殇ゞ 提交于 2019-12-06 07:32:43

问题


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.


回答1:


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.




回答2:


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)




回答3:


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 (i.e. adb shell) and type in:

mount -o remount,rw /sdcard




回答4:


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



来源:https://stackoverflow.com/questions/6604170/android-emulator-sdcard-permissions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!