How do I display data from my database in a listview?

I can't see anywhere that you are assigning your database cursor to the ListView via a ListAdapter (CursorAdapter) I think you need to do the google Notepad tutorials do all 3 but even just Notepad1 Tutorial explains about linking a SimpleCursorAdapter to a ListView. Look at this tutorial and pay particular attention to the fillData() method private void fillData() { // Get all of the notes from the database and create the item list Cursor c = mDbHelper.fetchAllNotes(); startManagingCursor(c); String from = new String { NotesDbAdapter. KEY_TITLE }; int to = new int { R.id.

Text1 }; // Now create an array adapter and set it to display using our row SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout. Notes_row, c, from, to); setListAdapter(notes); } I hope that helps.

I can't see anywhere that you are assigning your database cursor to the ListView via a ListAdapter (CursorAdapter). I think you need to do the google Notepad tutorials do all 3 but even just Notepad1 Tutorial explains about linking a SimpleCursorAdapter to a ListView. Look at this tutorial and pay particular attention to the fillData() method private void fillData() { // Get all of the notes from the database and create the item list Cursor c = mDbHelper.fetchAllNotes(); startManagingCursor(c); String from = new String { NotesDbAdapter.

KEY_TITLE }; int to = new int { R.id. Text1 }; // Now create an array adapter and set it to display using our row SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout. Notes_row, c, from, to); setListAdapter(notes); } I hope that helps.

Private void displayclients(long clientId) { // TODO Auto-generated method stub db.open(); Cursor results = db. GetClient(clientId); if (results.moveToFirst()) { Toast. MakeText(this, "Name: "+results.

GetString(1)+" "+results. GetString(2), Toast. LENGTH_LONG).show(); } – Gsam Apr 19 at 14:28 Just make sure to look at the tutorial.

Yes you can think of your displayClients() similar to the google notepad tutorial fetching data in the fillData() method. I amended my answer with the code – wired00 Apr 19 at 14:32 thanks WiredOO, I hope that helps. Will also look at the google notepad tutorials – Gsam Apr 19 at 14:37 thanks Wired00, been out for long but this helped me alot.

Thumbs up. Thanks – Gsam May 9 at 9:43 @wired00, worked out well. – Gsam May 9 at 13:29.

First I open the database and add a client's name, surname and number. Then I close the database. From here, I get confused and as to how I can display the name and surname in one line but in a listview leaving behind the number.

//methods for opening and closing the database, as well as the methods for adding/editing/deleting rows in the table. Db = DBHelper. //made comments will be taken care of i.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions