Android:以编程方式将文件从 SD 卡复制到应用程序的 Assets 文件夹

标签 android assets sd-card

我想将文件从 SD 卡复制到 android 中应用程序的 Assets 文件夹中。请帮助我以编程方式执行此操作。

最佳答案

不幸的是,你不能。 应用程序 Assets 文件夹是只读的,因此您不能以编程方式在其中存储(写入)您的数据。

(取自 AssetManager Doc ):

This class presents a lower-level API that allows you to open and read raw files that have been bundled with the application as a simple stream of bytes.

另请参阅 Managing Projects | Android Developers :

assets/ This is empty. You can use it to store raw asset files. Files that you save here are compiled into an .apk file as-is, and the original filename is preserved. You can navigate this directory in the same way as a typical file system using URIs and read files as a stream of bytes using the AssetManager. For example, this is a good location for textures and game data.

关于Android:以编程方式将文件从 SD 卡复制到应用程序的 Assets 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23080541/

相关文章:

flutter - 如何在 flutter Package/Plugin 开发中添加 Assets ?

安卓+ eclipse : Can't push files to SD Card

android - 这是在 Android 中实现 RecyclerView 的错误方法吗?

android - 在 recyclerview 适配器中带有 if 条件的方法中缺少 return 语句

android - 字幕文本在三星 Galaxy S3 中无法正常工作

android - CursorIndexOutOfBoundsException 请求索引 0,大小为 0

java - Android:File()的 Assets 文件夹路径?

android - 如何从 .apk 文件中打包的 jar 文件加载类?

android - 如何为安卓模拟器创建SD卡镜像文件?

java - 如何播放sd文件夹中的视频