Android - 将文件从资产复制到/data/data 文件夹 [英] Android - Copy files from assets to /data/data folder

查看:87
本文介绍了Android - 将文件从资产复制到/data/data 文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的应用中使用一些文件.它们保存在资产文件夹中.我看到了关于 SO 的讨论,文件被从资产文件夹复制到/data/data/在内部存储上,然后被使用.代码我拿到了,但是我没有拿到的是,有什么需要将资产拷贝到内部存储?

I need to use some files in my app. They are kept in asset folder. I saw discussions on SO, where the files are being copied from asset folder, to /data/data/<package_name> on the internal storage, and then being used. I get the code, but what I do not get is, what is the need to copy the assets to internal storage?

推荐答案

我突然想到的一个原因是将现有的 C/C++ 代码与 NDK 一起使用时,需要文件路径并且您不想修改那个代码.

One reason that just popped up for me is when using existing C/C++ code with NDK that requires a path to a file and you don't want to modify that code.

例如,我正在使用一个需要一些数据文件的现有 C 库,并且唯一现有的接口是一些加载(字符*路径)"函数.

For example, I'm using an existing C library that needs some data files and the only existing interface is some "load( char* path )" function.

也许实际上有一些更好的方法,但我还没有找到.

Perhaps there is actually some better method but I have not found any yet.

这篇关于Android - 将文件从资产复制到/data/data 文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆