Getting Stored Data From Database Into Listview.
package one.two; import java.util.ArrayList; import java.util.List; import android.app.ListActivity; import android.database.Cursor; import android.inputmethodservice.Keyboard.R
Solution 1:
You are not populating the list with the data you retrieved. And, you should use SimpleCursorAdapter
in these cases:
privatevoidgetData() {
db.open();
List<String> items = newArrayList<String>();
Cursor c = db.getAllEntry();
c.moveToFirst();
ListAdapter adapter=newSimpleCursorAdapter(this,
R.layout.view_list, c,
newString[] {"date", "title"},
new int[] {R.id.toptext, R.id.bottomtext});
setListAdapter(adapter);
setListAdapter(entries);
db.close();
}
In this case I'm guessing your table has a column named date
and another named title
. Take a look at this example for further reference: SimpleCursorAdapters and ListViews
Post a Comment for "Getting Stored Data From Database Into Listview."