Rajath
Rajath

Reputation: 11926

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

Upvotes: 2

Views: 3986

Answers (2)

esse
esse

Reputation: 5539

make sure you have set permissions in your manifest file

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

Upvotes: 0

inazaruk
inazaruk

Reputation: 74780

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

Upvotes: 4

Related Questions