Beispiel #1
0
  public List<Tel_query> queryTel_query(String name) {
    List<Tel_query> ltt = new ArrayList<Tel_query>();
    SQLiteDatabase db = this.getReadableDatabase();
    Cursor count =
        db.rawQuery(
            "select count(*) c from (select * from tel_query where ggxh like ?)",
            new String[] {"%" + name + "%"});
    int c = 0;
    if (count.moveToNext()) {
      c = count.getInt(count.getColumnIndex("c"));
    }
    count.close();
    if (c <= 150) {
      Cursor cursor =
          db.rawQuery(
              "select * from tel_query where ggxh like ? order by ggxh",
              new String[] {"%" + name + "%"});
      while (cursor.moveToNext()) {
        Tel_query tt = new Tel_query();
        tt.setGgxh(cursor.getString(cursor.getColumnIndex("ggxh")));
        tt.setText(cursor.getString(cursor.getColumnIndex("text")));
        ltt.add(tt);
      }
      cursor.close();
    }

    return ltt;
  }
Beispiel #2
0
 public void saveTel_querys(List<Tel_query> lst) {
   SQLiteDatabase db = null;
   try {
     db = this.getWritableDatabase();
     db.beginTransaction();
     db.execSQL("delete from tel_query");
     for (Tel_query tt : lst) {
       Log.i("Tel_query", tt.getGgxh() + "--" + tt.getText());
       db.execSQL(
           "insert into tel_query(ggxh,text) values (?,?)",
           new String[] {tt.getGgxh(), tt.getText()});
     }
     db.setTransactionSuccessful();
   } catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } finally {
     db.endTransaction();
   }
 }