//按所有查询
btnAll.setOnClickListener(new OnClickListener(){
public void onClick(View v){
SQLiteDatabase m_dbSQLiteDatabase=null;
m_dbSQLiteDatabase=SQLiteDatabase.openOrCreateDatabase("/data/data/com.example.demo_01/xiao.db",null);
if(m_dbSQLiteDatabase!=null)
{
String strMsg="查到的数据:\n 编号 姓名 电话\n";
Cursor resultCursor=m_dbSQLiteDatabase.query("Address",new String[]{"User_Id","User_Name","User_Tel"},null,null,null,null,null);
if (resultCursor.moveToFirst()){
for(int i=0;i<resultCursor.getCount();i++){
strMsg+=" "+resultCursor.getString(0)+" "+resultCursor.getString(1)+" "+resultCursor.getString(2)+"\n";
resultCursor.moveToNext();
}
}
txtresult.setText(strMsg);
m_dbSQLiteDatabase.close();
}
}
});
FredZeng
相关分类