I have mounted an external ext4 hardrive from the device tree /dev/block/sda1 to /storage/emulated/legacy. My mainActivity is trying to access a file under /legacy/data/abc.txt. However it cannot get to it. The owner of /legacy/data is root.
Also, mainActivity tries to create a folder under /storage/sdcard0/results called folderx using foldername.mkdir(), but it cannot. /storage/sdcard0/results also is owned by root.
I have changed permission on both these folders using chmod 777. I suspect the problem is that root is the owner and mainActivity runs as a different user. However i dont know what the owner should be changed to.
Best How To :
Formatting an external NTFS hard drive to use on a CHT RVP
mkfs -t ext4 /location/of/hdd
Edit platform.xml in /system/etc/permisssions: reference http://technofaq.org/posts/2014/04/fixing-external-sd-card-write-issue-on-android-kitkat/ Add an additional group definition for the external storage permissions :
<group gid="media_rw" /> save the changes to the file restart the device
Mount the formatted hard drive on CHT RVP:
mount -t ext4 /dev/block/sda1 /storage/sdcard1 /* /dev/block is the device tree, /storage/sdcard1 is the location where you are mounting the hard drive
Change owner of the /storage/sdcard1 to media_rw:
chown -R media_rw:media_rw /storage/sdcard1
chmod -R 777 /storage/sdcard1
And done. You should be able to read/write to the external hard drive.