// Select Data
public String[] SelectData(String strMemberID) {
// TODO Auto-generated method stub
try {
String arrData[] = null;
SQLiteDatabase db;
db = this.getReadableDatabase(); // Read Data
Cursor cursor = db.query(TABLE_MEMBER, new String[] { "*" },
"MemberID=?",
new String[] { String.valueOf(strMemberID) }, null, null, null, null);
if(cursor != null)
{
if (cursor.moveToFirst()) {
arrData = new String[cursor.getColumnCount()];
/***
* 0 = MemberID
* 1 = Name
* 2 = Tel
*/
arrData[0] = cursor.getString(0);
arrData[1] = cursor.getString(1);
arrData[2] = cursor.getString(2);
}
}
cursor.close();
db.close();
return arrData;
} catch (Exception e) {
return null;
}
}
Code (Android-Java)
public void ShowData(String MemID)
{
// txtMemberID, txtName, txtTel
final TextView tMemberID = (TextView) findViewById(R.id.txtMemberID);
final EditText tName = (EditText) findViewById(R.id.txtName);
final EditText tTel = (EditText) findViewById(R.id.txtTel);
// new Class DB
final myDBClass myDb = new myDBClass(this);
// Show Data
String arrData[] = myDb.SelectData(MemID);
if(arrData != null)
{
tMemberID.setText(arrData[0]);
tName.setText(arrData[1]);
tTel.setText(arrData[2]);
}
}
Android Edit Update Data in SQLite Database (Android SQLite)