2011-10-17 51 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