Make external media writable

AndyDroid2012

Member
Licensed User
Longtime User
I made this a new thread, hope thats OK

Here is how you can make the removable media memory writable.

You will need to get ES File Explorer File Manager from Google Play Store.

Follow these instructions as the ES File Explorer Method

Step 1: Open ES File Explorer and select your "menu" button on your phone or android and then select "settings".
You will be checking the checkbox on two options.

Scroll down and check "Root Explorer" and select "yes" for the experimental feature.
Superuser will pop up so "allow" it and check "remember". (maybe old version of ES Explorer, mine did not ask)
Check "Mount File System". Select your "back" button on your phone.

Step 2: You should be at the sdcard partition. /sdcard
Press the back button to go up one folder to Root.
You should now be at root. /

Scroll down and select "etc". You should now be located in /etc.
Press on permissions.
You should now be in /etc/permissions

Step 3: Find platform.xml
Click on the folder and you should be prompted with a menu of choices.
Choose Open
Open with ES Notes Editor

Step 4. Edit the platform.xml in two places, adding new rows
find the WRITE_EXTERNAL_STORAGE permission.
Add an additional group definition for this permission...<group gid="media_rw" />

find the WRITE_MEDIA_STORAGE permission.
Add an additional group definition for this permission...<group gid="sdcard_rw" />

I put this row ahead of the existing media_rw but apparently order is not important

you should now have

B4X:
    <permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
        <group gid="sdcard_rw" />
        <group gid="media_rw" />
    </permission>

    <permission name="android.permission.WRITE_MEDIA_STORAGE" >
        <group gid="sdcard_rw" />
        <group gid="media_rw" />
    </permission>

Save the file.

ES File Explorer will make a copy platform.bak


Step 5: Reboot your android.



TESTING:

I used the screen capture demo here on the forum and changed lines

B4X:
Sub btnSave_Click
 
'   SignatureCapture.Save(SD, File.DirRootExternal & "/Pictures/Screenshots", "sign" & NumberFormat(ctr,0,0)  & ".png")
'   ToastMessageShow("Signature saved to: " & File.Combine(File.DirRootExternal & "/Pictures/Screenshots", "sign" & NumberFormat(ctr,0,0)  & ".png"), True)


   SignatureCapture.Save(SD,  "/mnt/extsd/", "sign" & NumberFormat(ctr,0,0)  & ".png")
   ToastMessageShow("Signature saved to: " & "/mnt/extsd/" & "sign" & NumberFormat(ctr,0,0)  & ".png", True)


   'The next line will load the image and set it as the activity background.
'   Activity.SetBackgroundImage(LoadBitmap(File.DirRootExternal, "sign.png"))
    ctr = ctr +1
   btnClear_Click
End Sub


It worked without any need to add code like android.permission.WRITE_EXTERNAL_STORAGE in my b4a code.


So, yes we can access extsd or whatever name your removable storage is called. Note that the literal extsd is my external media in the code in SignatureCapture. Yours may differ.

Maybe the smart guys here do it other ways but for a newbie, this was a scary prospect and I tested doing it a number of times on other files until I became familiar with ES Explorer, afraid I was going to brick the android after reboot.
Anyway, works for me.
 
Top