SanHappy SanHappy - 1 year ago 89
MySQL Question

Show specific row listiview android (data from MySQL)

Show a ListView with data in MySQL , what I want is to go to specific listivew row where the user 's email is.
E-mail was previously recorded in SQLITE and MySQL , the listview includes different users with different emails.
This is my code:

SimpleAdapter adapter2 = new SimpleAdapter(this,list, R.layout.b_server_list_item,
new String[]{Config.TAG_EMAIL,Config.TAG_ID,Config.TAG_FOTO,Config.TAG_NOMBRE,Config.TAG_PESO,Config.TAG_VASOS,Config.TAG_SEGUIMIENTO},
new int[]{,,,,,,}) {

public View getView (int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView receiverIdTextView = (TextView) view.findViewById(;
int pos = position+1;
receiverIdTextView.setText("" + pos); //this all work OK

SQLiteDatabase datos;
datos = getApplicationContext().openOrCreateDatabase("DBMIEMBRO", Context.MODE_PRIVATE, null);
String query_email = "SELECT * from usermail order by _id DESC limit 1";
Cursor c_email = datos.rawQuery(query_email, null);
//i comproved if has data. It has and display ok in TextView

//My proble begin here, i dont know if is the correct way to do what i want
String listEmail = (c_email.getString(c_email.getColumnIndex(DBhelper.KEY_EMAIL)));
if (listEmail.equals({

return view;

This not work, display all data ok but this listview not show specific row where de user email is. I want check if the email stored in SQLITE is in the list (display MySQL) and if is yes, show specific row. In my code i ckecked and i can see that i have the same mail in one of the rows (display from MySQL) and in the textview (display from SQLITE).

Answer Source

This below check completely wrong. Your checking string value with integer

       if (listEmail.equals({


Instead of that have a mail_id handy and check against it.

more inside getview implementing database call will slow down your list view scroll