mardi 20 janvier 2015

Retrieving multiple records from sqlite and saving all in a TextView in android

I have a table and in one of the table row I have a TextView. I am retrieving the records from sqlite into my TextView. I know that I am retrieving all the values I need, but I am able to print only the last record in the TextView.


I need to retrieve all the records in the TextView. Its not append which I require. Because I have duplicate values as well in the sqlite. and the TextView is inside the for loop too. so I just need all the values in a single place with different identification so that I can compare among them to print all the selected. I tried to use List but was not successful enough.


Here is my code snippet. Any help is much appreciated. Thanks in advance.



restriction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("I am here", "Restriction module");
c5.moveToFirst();
c6.moveToFirst();
c.moveToPosition(position);
if(restrictiontext.getVisibility()==View.VISIBLE)
{
restrictiontext.setVisibility(View.GONE);
row13.setVisibility(View.GONE);
count=0;
}
else {
for (int j = 0; j < c5.getCount(); j++) {

if (c.getString(c.getColumnIndex("PBS_CODE")).equalsIgnoreCase(c5.getString(c5.getColumnIndex("PBS_CODE")))) {

for (int i = 0; i < c6.getCount(); i++) {
if (c5.getString(c5.getColumnIndex("INDICATION_ID")).equalsIgnoreCase(c6.getString(c6.getColumnIndex("INDICATION_ID")))) {



restrictiontext.setVisibility(View.VISIBLE);
row13.setVisibility(View.VISIBLE);
restrictiontext.setText(c6.getString(c6.getColumnIndex("TEXT")));


}
c6.moveToNext();
}
}
c5.moveToNext();
c6.moveToFirst();
}
}

Aucun commentaire:

Enregistrer un commentaire