Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

Android sqlite and listview

0

46 views

is there an exampl on how to use listview with sqlite to read all rows in table at once or what do i change in the curser to make it read all the tittles at once

//---get all titles---
            db.open();
            Cursor c = db.getAllTitles();
            String text = "";
            if (c.moveToFirst())
            {
                do {          
                    DisplayTitle(c, text);
                } while (c.moveToNext());
            }
            db.close();
        }

        public void DisplayTitle(Cursor c, String text)
        {
     ListView.setText("id: " + c.getString(0) + "\n" + "ISBN: " + c.getString(1) 
+ "\n" + "TITLE: " + c.getString(2) + "\n" + "PUBLISHER:  " + c.getString(3));
} 






//---retrieves all the titles---
    public Cursor getAllTitles() 
    {
        return db.query(DATABASE_TABLE, new String[] {
                KEY_ROWID, 
                KEY_ISBN,
                KEY_TITLE,
                KEY_PUBLISHER}, 
                null, 
                null, 
                null, 
                null, 
                null);
    }

asked June 24, 2011 2:38 am CDT
moe
posted via StackOverflow

0 Answers

Be the first to answer this question

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
SQLite & Android
March 11, 2011