|
public void onClick(View arg0) {
String result = null;
DB db=new DB(getApplicationContext());
int a=Integer.parseInt(e1.getText().toString());
Cursor c= db.query();
if(c.moveToFirst()){
for(int i=0;i<c.getCount();i++{
c.move(i);
if(c.getInt(0)==a){
String name=c.getString(1);
String password=c.getString(2);
result="id="+a+";\n"+"姓 名:"+name+";\n"+"密码:"+password+";";
break;
}
}
builder.setTitle("查询结果:");
builder.setMessage(result);
builder.setPositiveButton("确定", null);
builder.create().show();
}
这时有的可以查 但有的不能查,
public void onClick(View arg0) {
String result = null;
DB db=new DB(getApplicationContext());
int a=Integer.parseInt(e1.getText().toString());
Cursor c= db.query();
if(c.moveToFirst()){
for(int i=0;i<c.getCount();i++{
if(c.getInt(0)==a){
String name=c.getString(1);
String password=c.getString(2);
result="id="+a+";\n"+"姓 名:"+name+";\n"+"密码:"+password+";";
break;
}
c.moveToNext();
}
builder.setTitle("查询结果:");
builder.setMessage(result);
builder.setPositiveButton("确定", null);
builder.create().show();
}
这样就可以查了 问题就出在move(i); 和c.moveToNext();上面 有人遇到这样的问题不 指点下
|
|