chmod失败:android中的EPERM(不允许 *** 作)?

chmod失败:android中的EPERM(不允许 *** 作)?,第1张

概述我想在sdcard或外部SD卡中创建数据库为此我已经尝试了这个代码并使用这个我已经在SD卡中成功创建了数据库,但在logcat中它给了我如下警告logcat的07-1814:18:22.140:W/FileUtils(8595):Failedtochmod(/mnt/sdcard/peakmedia/DB_PMD):libcore.io.ErrnoException:chmod

我想在sdcard或外部SD卡中创建数据库为此我已经尝试了这个代码并使用这个我已经在SD卡中成功创建了数据库,但在logcat中它给了我如下警告

logcat的

07-18 14:18:22.140: W/fileUtils(8595): Failed to
chmod(/mnt/sdcard/peakmedia/DB_PMD): libcore.io.ErrnoException: chmod
Failed: EPERM (Operation not permitted)

DB_Helper.java

public class DB_Helper extends sqliteOpenHelper{    public DB_Helper(Context context)     {           super(context, Environment.getExternalStorageDirectory().getabsolutePath()                        + file.separator + DB_Constant.DB.file_DIR                        + file.separator + DB_Constant.DB.DATABASEname, null, DB_Constant.DB.DB_VERSION);    }    @OverrIDe    public voID onCreate(sqliteDatabase db)     {        String  query=String.format(DB_Constant.CREATE_table_query.CREATE_MYfileS_table);        db.execsql(query);        query=String.format(DB_Constant.CREATE_table_query.CREATE_MYUSERS_table);        db.execsql(query);        query=String.format(DB_Constant.CREATE_table_query.CREATE_MYPLAYList_table);        db.execsql(query);        query=String.format(DB_Constant.CREATE_table_query.CREATE_MYDEVICE_table);        db.execsql(query);    }     @OverrIDe     public voID onUpgrade(sqliteDatabase db, int oldVersion, int newVersion)      {            if(newVersion > oldVersion)            {                   db.execsql("DROP table IF EXISTS "+ DB_Constant.table.MYfileS);                onCreate(db);                db.execsql("DROP table IF EXISTS "+ DB_Constant.table.MYUSERS);                onCreate(db);                db.execsql("DROP table IF EXISTS "+ DB_Constant.table.MYPLAYList);                onCreate(db);                db.execsql("DROP table IF EXISTS "+ DB_Constant.table.MYDEVICE);                onCreate(db);            }     }}

解决方法:

刚刚解决了这个问题.

你必须让你的应用程序加入linux build以授予它SYstem权限.

>将此行添加到AndroID.mk中

LOCAL_CERTIFICATE:=平台
>将其添加到AndroIDManifest.xml的清单节点中

机器人:sharedUserID = “androID.uID.system”
>生成apk并将其推入/ system / app /
>现在你可以试着跑了

final String command = "chmod 777 /data/ena";Process p = Runtime.getRuntime().exec(command);

要么

file file = new file("/data/ena");if (file.exists()) {    boolean result = file.setExecutable(true);    Log.e(TAG, "trpb67, RESulT IS " + result);}

结果的值应该是真的

总结

以上是内存溢出为你收集整理的chmod失败:android中的EPERM(不允许 *** 作)?全部内容,希望文章能够帮你解决chmod失败:android中的EPERM(不允许 *** 作)?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1097926.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存