public void updataDB(HSms sms, HSmsApplication application) {
    HLog.i("updata buffer list--------------------->>>");
    mDatabase = mDbOpenHelper.getWritableDatabase();
    // String where = ADDRESS + "=" + sms.address;
    String where = ID + "=" + sms.threadid;
    Cursor cursor = mDatabase.query(TABLE_NAME, null, where, null, null, null, null);
    int len = sms.address.split(",").length;
    if (cursor.getCount() > 0) { // 旧信息
      cursor.moveToFirst();
      String where1 = ID + "=" + sms.threadid;
      HThread model = getHThread(cursor);
      String count = cursor.getString(cursor.getColumnIndex(COUNT));
      String noReadSmsCount = cursor.getString(cursor.getColumnIndex(NOREADCOUNT));
      String type = model.type;
      mDatabase.delete(TABLE_NAME, where1, null);
      ContentValues values = getValue(model);

      if (!sms.type.equals("3")) {
        values.put(TYPE, type);
      } else {
        values.put(TYPE, sms.type);
      }

      values.put(ADDRESS, sms.address);
      values.put(READ, sms.read);
      values.put(BODY, sms.body);
      values.put(NOREADCOUNT, String.valueOf(Integer.parseInt(noReadSmsCount) + 1));
      if (!sms.type.equals("3")) {
        values.put(COUNT, String.valueOf(Integer.parseInt(count) + len));
      }
      values.put(TIME, Long.parseLong(sms.time));
      mDatabase.insert(TABLE_NAME, null, values);
    } else { // 新信息
      HAddressBookManager abm = new HAddressBookManager(application);
      HThread thread = new HThread(application);
      thread.address = sms.address;
      thread.sms.body = sms.body;
      thread.count = "1";
      thread.sms.threadid = sms.threadid;
      thread.name = abm.getNameByNumber(sms.address);
      thread.type = sms.type;
      thread.sms.read = sms.read;
      if (!thread.type.equals("3")) {
        thread.count = String.valueOf(len);
      }
      Bitmap headBp = null;
      if (thread.name.split(",").length == 1) {
        headBp = abm.getContactPhoto(thread.name, thread.address);
      }
      thread.headbm = headBp;
      thread.mark = "0";
      thread.sms.time = sms.time;
      ContentValues cv = getValue(thread);
      mDatabase.insert(TABLE_NAME, null, cv);
    }
    cursor.close();
    mDatabase.close();
  }
 public HThread getHThread(Cursor cursor) {
   HAddressBookManager abm = new HAddressBookManager(mApplication);
   HThread model = new HThread();
   model.sms.threadid = cursor.getString(cursor.getColumnIndex(HBufferList.ID));
   model.name = cursor.getString(cursor.getColumnIndex(HBufferList.NAME));
   model.address = cursor.getString(cursor.getColumnIndex(HBufferList.ADDRESS));
   model.count = cursor.getString(cursor.getColumnIndex(HBufferList.COUNT));
   model.sms.body = cursor.getString(cursor.getColumnIndex(HBufferList.BODY));
   model.sms.time = String.valueOf(cursor.getLong(cursor.getColumnIndex(HBufferList.TIME)));
   model.type = cursor.getString(cursor.getColumnIndex(HBufferList.TYPE));
   model.sms.read = cursor.getString(cursor.getColumnIndex(HBufferList.READ));
   String strHead = cursor.getString(cursor.getColumnIndex(HBufferList.HEADBM));
   model.ismms = cursor.getString(cursor.getColumnIndex(HBufferList.ISMMS));
   // model.noReadCount = cursor.getString(cursor.getColumnIndex(HBufferList.NOREADCOUNT));
   Bitmap bitmap = null;
   if (strHead.equals("1")) {
     bitmap = abm.getContactPhoto(model.name, model.address);
   }
   model.headbm = bitmap;
   return model;
 }