private static final String TABLENAME = "mytab";
private SQLiteDatabase db = null;
public Qu(SQLiteDatabase db) {
this.db = db;
}
public List<String> find() {
List<String> all = new ArrayList<String>();
String sql = "select id,name,birthday from mytab";
Cursor result = db.rawQuery(sql, null);
从第一个开始查 不是最后一个 移动到下一个
for (result.moveToFirst(); !result.isAfterLast(); result.moveToNext())
{
all.add(result.getInt(0)+result.getString(1)+result.getString(2));
}
db.close();
return all;
}
List<String> all = new ArrayList<String>();
String[] da ={"id","name","birthday"};
Cursor result = db.query(TABLENAME, da, null, null, null, null,null);
for (result.moveToFirst(); !result.isAfterLast(); result.moveToNext())
{
all.add(result.getInt(0)+result.getString(1)+result.getString(2));
}
db.close();
return all;
String sql = "select id,name,birthday from mytab where name like ? or birthday like ?";
String keyword = "5";
String[] args = new String[] { "%" + keyword + "%", "%" + keyword + "%" };
Cursor result = db.rawQuery(sql, args);
for (result.moveToFirst(); !result.isAfterLast(); result.moveToNext()) {
all.add(result.getInt(0) + result.getString(1)
+ result.getString(2));
}
return all;