如何将文件复制到android的文件系统?
如何将文件复制到android中的文件系统(位置)?我怎样才能访问它?
How can I copy files to the file system (place) in android? How can I access it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
将文件从 android 复制到本地
将文件从本地复制到 android
copy files from android to local
copy file to android from local
我不确定这是否是您要问的,但这是对您的问题的另一种解释:
您可以将文件放置在开发计算机上项目的
assets
文件夹中。它们将被捆绑到 apk 文件中,然后通过 AssetManager 类访问它们。服务或活动类中的类似内容:这将允许您读取这些文件的内容。但我不相信你可以写信给他们。如果您需要在应用程序的存储沙箱中读取和写入文件,还有其他选项。这是通过调用
openFileOutput()
来完成的。我应该注意的是,用户始终可以通过 ddms 访问设备上的文件,但其他应用程序将无法访问存储在应用程序存储沙箱中的文件。编辑根据您的评论,您可能希望使用
从代码写入文件。必须从
Activity
或Service
(扩展Context
的东西)内调用此代码。该文件将存储在手机的文件系统中,而不是存储在 SD 卡上。普通用户将无法访问这些文件。如果用户知道如何启用 USB 调试,那么他们将能够访问它们,而且确实没有办法解决这个问题。I'm not sure if this is what you're asking, but here's another interpretation of your question:
You can place files in the
assets
folder in the project on your development machine. They will be bundled into the apk file and then access them through theAssetManager
class. Something like this from within a Service or Activity class:This will allow you to read the contents of those files. I don't believe you can write to them though. There are other options for if you need to read and write files in your application's storage sandbox. This is done by calling
openFileOutput()
. I should note though that the user can always access the files on the device through ddms but other applications won't be able to access files stored in your application's storage sandbox.Edit Based on your comment, you probably want to use
to write to a file from your code. This code must be called from within an
Activity
orService
(something that extendsContext
). This file will be stored on the phone's file system and not on the sdcard. These files will not be accessible to the average user. If users know how to enable usb debugging then they will be able to access them and there is really no way around this.您可以使用:
如果您的设备有 SD 卡,则将为您提供
/sdcard
,或者在其他情况下提供不同的信息。例如爱可视。You can use:
That will give you
/sdcard
if your device has an sdcard, or something different in other cases. For example the Archos.之前我花了一些时间研究android的系统文件,但几乎总是使用android x86,我发现android内部的/system文件夹是只读的,
它是一个格式为SFS格式的图像,这是只读图像linux 的格式,所以我认为你不能复制这个文件夹中的一些东西。我不确定是否有root android。希望它能帮助你。
I took some time to research about android's system files earlier, but almost always with android x86, i found out that the /system folder inside android is read-only,
it is an image with format is SFS format, this is read-only image format of linux so i don't think you can copy some thing inside this folder. I not sure about rooted android. Hope it will help you.
您可以通过在文件前面加上点(例如:.myfile)来隐藏 SD 卡中的文件
You can probably hide your file in the sdcard by prefixing it with a dot (ex: .myfile)