The code you show doesn't contain the issue you describe as there is no code that would use the cursor.
It seems strange that you close the database before reading from the cursor. The usual course of events is open the database, create the cursor, read from the cursor, close the cursor, close the database. Btw. In Java variable names start with a lower case letter. On Sat, May 29, 2010 at 1:49 PM, Vikram <[email protected]> wrote: > I have the following piece of code, which is behaving in a very > strange manner. > > 1. When I run this code, the Cursor always carries 0 rows. > 2. I know this sounds stupid, but when I debug the code, it carries > all the rows in my table. > 3. Alternatively, when I do not close the database and run through it, > it carries all the rows. > > Is this a timing issue of some sort? Has it anything to do with the > cursor's lifetime? Will the cursor be invalid if I close the database > and the openlitehelper? Why in that case do I get valid data if I > debug through the code. > > //Open the database > openForRead(); > > StringBuilder query = new StringBuilder("SELECT "); > > //Append the projection columns > SQLiteQueryBuilder.appendColumns(query, projection); > > //Force append the _ID column > SQLiteQueryBuilder.appendColumns(query, new String[]{", " + > _IDColumnName + " AS " + BaseColumns._ID}); > > //From tablename > query.append("FROM " + tableName); > > //Query the database and return the cursor > C = database.rawQuery(query.toString(), null); > > //Close the database > close(); > > return C; > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

