[Android Software Development] kainjinez:
Hello everyone,

I'm going to build an app which helps people access SMS Sqlite file to add/edit/delete messages.

I found that SMS stored in:

Then I used a class named DatabaseHandler extends SQLiteOpenHelper to manage add,edit,delete records.

Then in MainActivity, i create an AsyncTask to run

Shell.SU.run("su;chmod 777 /data/data/com.android.providers.telephony/databases/mmssms.db");

It require root access first, then chmod mmssms.db to 777 (i think it help me modify it).

After that, I call this to add new SMS:

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);

But it result in some error logcat code. I dont know what i did wrong. Please help. Thanks.

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 (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)