Category Archives: Android

Android FTP Server Project – How to Give Apps Write Permissions to External Storage Devices

I recently purchased an inexpensive ($35~ on FastTech.com) Android Mini PC to replace the old Windows XP computer I had running an FTP server for offsite web server backups. It’s smaller, more secure, and uses a lot less power than the old computer did. However, with the stock Android ROM on the device, writing to external storage devices (for example, a USB drive) with apps was disabled. To solve this, I temporarily rooted the device and modified the permissions file, which worked perfectly. In this post, I’ll go over exactly what I did to get the permissions working.

What I received from FastTech - Dime is for size reference.

What I received from FastTech – Dime is for size reference.

Specifications

Specifications

Close-up of the Mini PC itself. It's actually designed to be used as an HDMI TV Media Stick (Similar to the Chromecast).

Close-up of the Mini PC itself. It’s actually designed to be used as an HDMI TV Media Stick (Similar to the Chromecast).

After connecting the device to my computer (make sure you use a USB data cable, the cable that comes with the Mini PC is power only), I was able to use the Android Debug Bridge (ADB) within Android’s developer tools to temporarily root the device. To use ADB, download and install the Android SDK from Google’s website.

Once I had shell access on the device, (Commands: ./adb remount, ./adb root, ./adb shell in that order), I navigated to the folder containing the platform.xml permissions file (Command: cd /system/etc/permissions), and displayed its contents so that I could edit them later (Command: cat platform.xml). With the contents of platform.xml copied, I was able to logout (Command: exit), and in a text editor, added write permissions by changing these lines:

1
2
3
    <permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
        <group gid="sdcard_rw" />
    </permission>

to this:

1
2
3
4
    <permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
        <group gid="sdcard_rw" />
        <group gid="media_rw" />
    </permission>

After saving the new platform.xml file, I uploaded it to the device with ADB (Command: ./adb push “PATH_TO_EDITED_PLATFORM_XML_ON_YOUR_COMPUTER/platform.xml” “/system/etc/permissions/platform.xml”), logged back into the shell, and viewed the files contents again to make sure the changes were saved successfully. With that confirmed, I rebooted the Mini PC, and was able to write to the USB drive from apps that I previously couldn’t.

Great success!

In order, the commands I used were (from the directory that adb was located in):

  1. ./adb remount
  2. ./adb root
  3. ./adb shell
  4. cd /system/etc/permissions
  5. cat platform.xml
  6. exit
  7. ./adb push “PATH_TO_EDITED_PLATFORM_XML_ON_YOUR_COMPUTER/platform.xml” “/system/etc/permissions/platform.xml”
  8. ./adb shell
  9. cd /system/etc/permissions
  10. cat platform.xml
  11. reboot (ONLY AFTER PLATFORM.XML WAS CONFIRMED TO HAVE BEEN SUCCESSFULLY UPLOADED)

Please note that this was done on a Mac, and may not work if you’re on Windows. Linux commands should be the same.