2011-10-17 107 views
0

我用這個方法Uri.getHost()使用它們的URI content://sms/inbox進行SMS備份。恢復短信內容?

而且,我已將其更改爲使用this的文件格式。

現在,我需要將這些內容正確地恢復到他們的數據庫。我將使用什麼類型的方法?任何人指導我。這對我來說非常有用。提前致謝。

回答

1

檢查這個代碼插入到短信內容提供商:

ContentValues initialValues = new ContentValues(); 
initialValues.put("address", "9953834074111"); 
initialValues.put("date", "1308281011976"); 
initialValues.put("body", "Body of this"); 
initialValues.put("type", "1"); 
getContentResolver().insert(smsuri, initialValues); 

檢查是否插入,或使用不卜:

Cursor cursor1 = getContentResolver().query(smsuri, null, null, null, null); 
    if (cursor1.moveToFirst()) { 
     do { 
      if((cursor1.getString(cursor1.getColumnIndex("address"))).equalsIgnoreCase("9953834074111")){ 
       String address = cursor1.getString(cursor1.getColumnIndex("address")); 
       String date = cursor1.getString(cursor1.getColumnIndex("date")); 
       String body = cursor1.getString(cursor1.getColumnIndex("body")); 
       String type = cursor1.getString(cursor1.getColumnIndex("type")); 
       Log.v("address",address); 
       Log.v("date",date); 
       Log.v("body",body); 
       Log.v("type",type); 
      } 
     } while (cursor1.moveToNext()); 
    } 
+0

你好@Venky我用你的代碼來存儲一些值,我在收件箱中收到此消息,但只有一個值。當我通過各種價值觀循環時,我甚至沒有一個單一的。 – Vish