我要构建一个应用程序,帮助人们访问SMS Sqlite文件以添加/编辑/删除邮件。 我发现SMS存储在这个根目录中:
Shell.SU.run("su;chmod 777 /data/data/com.android.providers.telephony/databases/mmssms.db");
然后我用一个名为DatabaseHandler的类扩展SQLiteOpenHelper来管理添加,编辑,删除记录。 之后,在MainActivity中,我创建一个AsyncTask来获取SU访问权限,并创建一个db来修改它的chmod 777。
DatabaseHandler db = new DatabaseHandler(this);
SMS sms = new SMS();
sms.addNewSMS("+84982631555",System.currentTimeMillis(),System.currentTimeMillis(),0,"Test SMS","+84982000001",0,"123456789",0,0);
db.addSMS(sms);
然后我打电话给这样的话来添加短信:
6-28 00:06:02.634 27705-27705/net.truonghieu.modifysmsremoteroot W/SQLiteLog: (28) failed to open "/data/data/com.android.providers.telephony/databases/mmssms.db-wal" with flag (131138) and mode_t (1ff) due to error (13)
06-28 00:06:02.634 27705-27705/net.truonghieu.modifysmsremoteroot W/SQLiteLog: (28) failed to open "/data/data/com.android.providers.telephony/databases/mmssms.db-wal" with flag (131072) and mode_t (1ff) due to error (13)
06-28 00:06:02.634 27705-27705/net.truonghieu.modifysmsremoteroot E/SQLiteLog: (14) cannot open file at line 31517 of [2ef4f3a5b1]
06-28 00:06:02.634 27705-27705/net.truonghieu.modifysmsremoteroot E/SQLiteLog: (14) os_unix.c:31517: (13) open(/data/data/com.android.providers.telephony/databases/mmssms.db-wal) -
06-28 00:06:02.644 27705-27705/net.truonghieu.modifysmsremoteroot E/SQLiteLog: (1806) unable to open database file
06-28 00:06:02.644 27705-27705/net.truonghieu.modifysmsremoteroot E/SQLiteDatabase: Failed to open database '/data/data/com.android.providers.telephony/databases/mmssms.db'.
android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (code 1806): , while compiling: PRAGMA journal_mode
#################################################################
Error Code : 1806 (SQLITE_CANTOPEN_EACCES)
Caused By : Application has no permission to open the specified database file.
(unable to open database file (code 1806): , while compiling: PRAGMA journal_mode)
#################################################################
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1058)
at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:762)
at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:443)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:301)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:210)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:512)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:206)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:908)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:878)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:699)
at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:633)
at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:283)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at net.truonghieu.modifysmsremoteroot.helper.DatabaseHandler.addSMS(DatabaseHandler.java:82)
at net.truonghieu.modifysmsremoteroot.MainActivity.onClick(MainActivity.java:42)
at android.view.View.performClick(View.java:5697)
at android.widget.TextView.performClick(TextView.java:10826)
at android.view.View$PerformClick.run(View.java:22526)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
但是我在logcat中遇到了一些错误。这是:
=B$3=MAX($B$3:$M$3)
我不知道我做错了什么。这是我第一次使用root。请帮忙。感谢。