I pass data from another activity and use for args in querying in my database and I would like to query some data in my sqlite database and set it to edittext and textview. But it display nothing. When I check if there's some data been queried it return true. Please help
Here's the code in my first activity when clicking item on listview and passing data to another activity
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View
view, int position, long id) {
TextView temp = (TextView) view;
Intent i = new Intent(home.this, Update.class);
Bundle bundle = new Bundle();
bundle.putString("sulod", temp.getText().toString());
Pig pig = new Pig();
pig.pig_type = temp.getText().toString();
i.putExtras(bundle);
startActivity(i);
finish();
}
});
Code in my second activity
public void display(){
Bundle bundle = getIntent().getExtras();
String sulod = bundle.getString("sulod");
Cursor c = myDb.filList();
String sremarks = "";
String saddress = "";
int Id = 0;
while (c.moveToNext()) {
String name = c.getString(1);
if(name == sulod){
Id = c.getInt(0);
sremarks = c.getString(2);
saddress = c.getString(3);
}
}
id.setText(Id+"");
remarks.setText(sremarks);
address.setText(saddress);
}
And in my dbhelper
public Cursor filList() {
SQLiteDatabase db = this.getWritableDatabase();
String[] columns = {COL_1, COL_2, COL_3, COL_4};
return db.query(TABLE_NAME, columns, null, null, null,
null, null);
}