Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i am used this it display only one string



C#
StringBuilder ret = new StringBuilder();
       //String ret[];
       if(cc.moveToFirst())
       {
           for(int i=0;i<cc.getCount();i++)
           {
           String name=cc.getString(i);
           ret.append(name);
           cc.moveToNext();
           }
       }
       tv.setText(ret);


//thanks
Posted
Comments
AndroidVivek 3-Jan-13 1:25am    
what you firing the query in cursor...?

because it seems that cursor is returning one value ,
check what cursor.getCount() returns
and try to use while loop...

1 solution

Hi mekalareddy,

Try this code
Java
StringBuilder ret = new StringBuilder();
cursor.moveToFirst();
int i = 0;
while (!cursor.isAfterLast()) {
  ret.append(cursor.getString(i++));
  cursor.moveToNext();
}
// Make sure to close the cursor
cursor.close();
 
Share this answer
 
Comments
Member 11905691 16-Aug-15 23:22pm    
how to connect a sqlite database in android app

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900