安卓:可以写入到lib目录? [英] Android: Can write to lib dir?

查看:175
本文介绍了安卓:可以写入到lib目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能以编程方式复制文件到,或创建在/数据/数据​​/ application_package / lib目录下的符号链接?

在试图写的lib目录,我总是得到许可被拒绝的错误。
我已经定义

 <使用许可权的android:NAME =android.permission.WRITE_INTERNAL_STORAG​​E/>
<使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/>


解决方案

您不能写入的lib /,但是你并不需要。

您可以写信给你的应用程序的专用存储区域内的任何非预留位置,您可以从您已阅读设备上的任何文件使用System.load()与加载本地库和执行权限,全路径名,而不是的System.loadLibrary()与短库名称。

的外部存储器(SD卡)安装有一个非可执行标志,但在专用存储目录中的文件将是一个可行的解决方案。只是一定要让它只能通过您的应用程序可写,这样别的东西无法改变它在你的背后(那是因为你不能防止这样的修改外部存储是不可执行的外部存储的文件)

Is it possible to programmatically copy a file into, or create a symbolic link in the /data/data/application_package/lib directory?

When trying to write to the lib directory, I always get permission denied error. I have defined

<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

解决方案

You cannot write to lib/, however you do not need to.

You can write to any non-reserved location within your your application's private storage area, and you can load a native library from any file on the device for which you have read and execute permission, using System.load() with the full pathname, rather than System.loadLibrary() with the short library name.

The external storage (sdcard) is mounted with a non-executable flag, but a file in your private storage directory would be a workable solution. Just be sure to make it only writable by your application, so that something else can't change it behind your back (it is because you cannot protect external storage files from such modification that the external storage is non-executable)

这篇关于安卓:可以写入到lib目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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