求帮忙啊看看怎么获取已经存进去的数据
dpress.setOnClickListener(new android.view.View.OnClickListener(){
public void onClick(View v)
{
db = new Sql(getApplicationContext(), "store.db", null, 1);
sDatabase = db.getWritableDatabase();
if (userName01.getText().toString().equals("")
|| password01.getText().toString().equals(""))
{
DialogDemo.builder(AssistantRegister.this, "错误信息", "请填写完整信息!");
}
public void onClick(View v)
{
String i = use.getText().toString();
//String i1 = password.getText().toString();
String userName = "";
String userPw = "";
//编写数据库语句
String select_sql = "select username,password from user_info where username = '"
+ i + "'";
//执行语句
Cursor cursor = sDatabase.rawQuery(select_sql, null);
if(cursor!=null){
cursor.moveToFirst();
try
{
userName = cursor.getString(1);
userPw = cursor.getString(2);
}
catch (Exception e)
{
// TODO: handle exception
userName = "";
userPw = "";
}}
else
{
int id1=0;
String select = "select max(_id) from user_info";
Cursor seCursor = sDatabase.rawQuery(select, null);
seCursor.moveToFirst();
id1 = Integer.parseInt(seCursor.getString(0));
id1 += 1;
sDatabase.execSQL("insert into user_info values('" + id1 + "','"
+ userName01 + "','" + password01 + "')"
);
DialogDemo.builder(AssistantRegister.this, "提示", "注册成功,请返回登录界面登录");
//seCursor.close();
sDatabase.close();
}
主要是怎么获取数据库中的数据那里可能出错了,但不知怎么改正