0
我正在開發SMS備份和恢復應用程序。我可以將短信備份到CSV文件中。但是,當我嘗試恢復SMS時,SMS完全存儲在SMS數據庫中。但它們在Android中的消息應用程序中不可見。即使正確插入數據庫後,Android SMS也不會顯示
我正在使用Content Provider進行備份和恢復SMS。以下是我用於恢復SMS的代碼。
CSVReader reader = new CSVReader(new FileReader(csvFile));
Uri uri = Uri.parse("content://sms/");
String[] nextLine;
while ((nextLine = reader.readNext()) != null) {
ContentValues cv = new ContentValues();
cv.put("_id", nextLine[0]);
cv.put("thread_id", nextLine[1]);
cv.put("address", nextLine[2]);
cv.put("person", nextLine[3]);
cv.put("date", nextLine[4]);
cv.put("protocol", nextLine[5]);
cv.put("read", nextLine[6]);
cv.put("status", nextLine[7]);
cv.put("type", nextLine[8]);
cv.put("reply_path_present", nextLine[9]);
cv.put("subject", nextLine[10]);
cv.put("body", nextLine[11]);
cv.put("service_center", nextLine[12]);
cv.put("locked", nextLine[13]);
this.getContentResolver().insert(uri, cv);
}
請讓我知道,我在做什麼錯誤。我試圖在過去的一週內解決問題,但我還是不知道我在守則中的錯誤。代碼中缺少什麼?
您檢查了'this.getContentResolver()。的返回值嗎? – njzk2
是的。我檢查了返回值。它返回「content:// sms/1」,「content:// sms/2」。等等。它是正確的嗎? –
請幫忙。我嘗試了很多東西,但我無法找到解決我的問題的單一解決方案。 –