将文件推送到 Android 设备
我开发了一个读取文本文件的应用程序。在模拟器中我已将文件推入 \Data\Data\PackageName\File.txt 及其工作正常。但是,当我尝试将文件推送到设备中时,它会生成错误只读文件系统。我尝试将目录重新挂载为可写,但出现相同的错误。请帮助我如何将文件推送到设备中。
I have developed an application which read text file. In Emulator I have push the file in
\Data\Data\PackageName\File.txt and its working fine. But when I try to push file in Device its generate the error Read Only File System. I have try to remount directory as writable but the same error. Please help me how can I push file into device.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在尝试的文件夹在未 root 的手机上被锁定,即
没有写入权限
,我猜您正在尝试的设备不是 root 的设备。由于模拟器是一种开发人员设备,据说已经获得 root 权限,因此您可以将文件推送到该位置。因此,根据您的要求,您必须使用资产文件夹或文件系统存储
更新:如何使用资产文件夹
The folder you are trying is locked on non-rooted phones i.e
no write permission
and I guess the device you are trying on is not a rooted one. since emulator is sort of developer device which is said to be rooted that's why you can push file to that location.So depending on your requirement you have to either use Assest folder or File system storage
Update: How to use assest folder
在实践中,我们可以将此类文件推送到资产文件夹中。 Assets 文件夹供您放置要在应用程序中使用的原始文件。
In practice, we can push such file in assets folder. Assets folder is there for you to put such raw files to be used inside the application.