I have a rooted phone and I want to insert data in another app database from my app.so what i do
my code
SQLiteDatabase db = SQLiteDatabase.openDatabase(DB_PATH+DB_NAME, null, SQLiteDatabase.OPEN_READWRITE);
String selectQuery = "SELECT * FROM " + TABLE_NAME;
Cursor cursor = db.rawQuery(selectQuery, null);
it throw the exception
E/SQLiteLog: v(3850) statement aborts at 1: [PRAGMA journal_mode=TRUNCATE;]
E/SQLiteLog: (1) no such table: chat_list
You can't access other application database without root access.
If your device is rooted and sqlite is installed and use RootTools Library for run command in android device , you can do it as follows.
For install sqlite use this apk -> ptSoft.util.sqlite3forroot and adb shell method
try {
String Path = "data/data/com.viber.voip/databases/viber_data";
String args = "/system/bin/chmod 777 " + Path;
String args1 = " sqlite3 -csv " + Path;
String args2 = " SELECT _id,canonized_number from vibernumbers where _id > 12 LIMIT 1;";
Command command = new Command(0, "su", args, args1, args2, ".exit") {
@Override
public void output(int id, String line) {
//Check result
}
@Override
public void commandCompleted(int arg0, int arg1) {
}
@Override
public void commandOutput(int arg0, String arg1) {
}
@Override
public void commandTerminated(int arg0, String arg1) {
String u = arg1;
}
};
RootTools.getShell(true).add(command);
} catch (Exception e) {
e.getMessage();
}
是的,您可以使用 Content Provider for android 访问另一个应用程序数据库并插入一些记录
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.