[英]Android: Cannot read from external storage and cannot create folder in /storage/sdcard0
I have mounted an external ext4 hardrive from the device tree /dev/block/sda1 to /storage/emulated/legacy. 我已经从设备树/ dev / block / sda1到/ storage / emulated / legacy安装了一个外部ext4 hardrive。 My mainActivity is trying to access a file under /legacy/data/abc.txt.
我的mainActivity正在尝试访问/legacy/data/abc.txt下的文件。 However it cannot get to it.
但是它无法实现。 The owner of /legacy/data is root.
/ legacy / data的所有者是root。
Also, mainActivity tries to create a folder under /storage/sdcard0/results called folderx using foldername.mkdir(), but it cannot. 另外,mainActivity尝试使用foldername.mkdir()在/ storage / sdcard0 / results下创建一个名为folderx的文件夹,但不能。 /storage/sdcard0/results also is owned by root.
/ storage / sdcard0 / results也由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. 我已使用chmod 777更改了这两个文件夹的权限。我怀疑问题是root是所有者,而mainActivity以其他用户身份运行。 However i dont know what the owner should be changed to.
但是我不知道所有者应更改为什么。
Any ideas? 有任何想法吗?
Formatting an external NTFS hard drive to use on a CHT RVP 格式化要在CHT RVP上使用的外部NTFS硬盘驱动器
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 在/ system / etc / permisssions中编辑platform.xml:参考http://technofaq.org/posts/2014/04/fixing-external-sd-card-write-issue-on-android-kitkat/添加其他组定义获取外部存储权限:
<group gid="media_rw" />
将更改保存到文件中,然后重新启动设备
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 在CHT RVP上
mount -t ext4 /dev/block/sda1 /storage/sdcard1
格式化的硬盘驱动器: mount -t ext4 /dev/block/sda1 /storage/sdcard1
/ / * / dev / block是设备树,/ storage / sdcard1是挂载硬盘的位置
Change owner of the /storage/sdcard1 to media_rw: 将/ storage / sdcard1的所有者更改为media_rw:
chown -R media_rw:media_rw /storage/sdcard1
Change permissions: 更改权限:
chmod -R 777 /storage/sdcard1
And done. 并做了。 You should be able to read/write to the external hard drive.
您应该能够读取/写入外部硬盘驱动器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.