I have and EditText and I write on it the record which i want to appear jn TextView after clicking on the Button
So I need Retrieve a Row record from My DB and in specific Column and wat I want to retrieve is String Type **This is My Query but it doest work with me **
public String getCountryCode(String cc) {
Cursor cursor = null;
String Code = "";
try{
String selectQuery = "SELECT * FROM " + SQLITE_TABLE + " WHERE "
+ KEY_CODE + " = " + cc;
cursor = mDb.rawQuery(selectQuery, null);
if(cursor.getCount() > 0) {
cursor.moveToFirst();
Code = cursor.getString(cursor.getColumnIndex("KEY_CODE"));
}
return Code;
}finally {
cursor.close();
}
}
main activity
b.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
try{
String in =codeinput.getText().toString();
String c = dbHelper.getCountryCode(in);
CountryShow.setText(c);
}
catch(Exception e ){
Toast.makeText(listViewDisplay.this, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
});
Aucun commentaire:
Enregistrer un commentaire