这是我的桌子:
private static final String CREATE_table_EMPLOYEES = "CREATE table "+ tablename + "(" + ColUMNS[0] + " INTEGER PRIMARY KEY autoINCREMENT NOT NulL , " + ColUMNS[1] + " TEXT NOT NulL , " + ColUMNS[2] + " TEXT NOT NulL , " + ColUMNS[3] + " TEXT NOT NulL , " + ColUMNS[4] + " TEXT NOT NulL , " + ColUMNS[5] + " TEXT NOT NulL " + ");";
public List<Employee> getEmployees() { List<Employee> employees = new ArrayList<Employee>(); Cursor cur = db.query(dbHelper.tablename, columns, null, null, null, null, null); cur.movetoFirst(); // need to start the cursor first...! while(!cur.isAfterLast()) { // while not end of data stored in table... Employee emp = new Employee(); emp.setID(cur.getInt(0)); emp.setname(cur.getString(1)); emp.setCharge(cur.getString(2)); emp.setDepartament(cur.getString(3)); emp.setPhone(cur.getString(4)); emp.setEmail(cur.getString(5)); employees.add(emp); cur.movetoNext(); // next loop } cur.close(); // !important return employees; }
如果员工姓名==“ ali”,我想查询所有数据
请帮我.
解决方法:
I want to query all data if employee name ==”ali”.
查询方法中的第3和第4参数可用于在查询中添加WHERE子句.
这样做:
Cursor cur = db.query(dbHelper.tablename, columns, "name=?", new String[] { "ali" }, null, null, null);
总结 以上是内存溢出为你收集整理的android-如何查询SQLite数据库全部内容,希望文章能够帮你解决android-如何查询SQLite数据库所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)