No data appearing in ListView, using SimpleCursorAdapter?

At a quick guess, I'd say it's because you're closing the database connection in your onCreate method, before the list adapter has a chance to read any data from it. The Cursor itself doesn't contain all the data as soon as you run a query If you want your Activity to handle closing the database connection, you should do so in the onPause or onDestroy method.

At a quick guess, I'd say it's because you're closing the database connection in your onCreate method, before the list adapter has a chance to read any data from it. The Cursor itself doesn't contain all the data as soon as you run a query. If you want your Activity to handle closing the database connection, you should do so in the onPause or onDestroy method.

So I would have to put db.close() in another onDestroy method for my Arrival. Java? – User358218 Jul 26 '10 at 2:30 You would move it from onCreate() to onDestroy(), as then it matches the Activity lifecycle: the DB is opened when the Activity is created, and closed when it's destroyed (i.e.

The adapter no longer needs data access). – Christopher Jul 26 '10 at 2:32 I edited the code to public void onDestroy() { DBAdapter db = new DBAdapter(this); db.close(); } There is still no data shown in my listview. – User358218 Jul 26 '10 at 2:41 No, you're closing a new instance of the DBAdapter.

Move the db variable in onCreate() to a field so that it's accessible from onDestroy. – Christopher Jul 26 '10 at 10:30 Also, you could check at onCreate whether the Cursor you're getting back actually contains the data you expect, if you're not calling db.close() from onCreate any more. – Christopher Jul 26 '10 at 10:31.

Also, use the actual column names for any other columns that you're requesting the data for.

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