开发者

Make Android sdcard read-only

I need 开发者_开发知识库to test a scenario where the sdcard (or atleast a particular directory) is read-only. Does anyone know how I can do this on the emulator?

Basically I want to mount the sdcard as read-only. I tried the following command in adb shell, but it doesn't work.

mount -o remount r /sdcar


Here is how I managed to remount sdcard in read-only mode:

Step 1.
Execute mount and see the list of mounted directories. Note the one with /sdcard or /mnt/sdcard in it.

On my Android 1.6 emulator:

/dev/block//vold/179:0 /sdcard vfat rw,dirsync,nosuid,nodev,...

Step 2.

Execute next command:

mount -o remount,ro <block> <sdcard>

Where <block> and <sdcard> are first two items taken from mount output line with sdcard.

In my case the command would be:

mount -o remount,ro /dev/block//vold/179:0 /sdcard


make sure you have set permissions in your manifest file

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜