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 prompt开发者_开发百科s 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 (i.e. adb shell) and type in:
mount -o remount,rw /sdcard
Just a guess-- but perhaps you've configured the emulator with 0 external storage?
精彩评论