title: Android. Empty Cursor
body: <p>I copied database file from device and opened in SQLite client. Same query in the SQLite client returns results as expected but Android <strong>sometimes</strong> returns empty cursor. I can't explain why sometimes cursor returns 0 rows. SQLiteDatabase object is always opened per application because there is lots of requests to database per one task.</p>
  
  <pre><code>SQLiteDatabase database = this.getReadableDatabase();
  try {
      Cursor cursor = database.rawQuery(query, null);
      try {
          Log.d("Cursor rows count size: ", String.valueOf(cursor.getCount()));
          if(cursor.moveToFirst()) {
              do {                
                  Long a= cursor.getLong(cursor.getColumnIndex(TableA.a));
                  String b = String.valueOf(cursor.getInt(cursor.getColumnIndex(TableA.b)));
                  String c = cursor.getString(cursor.getColumnIndex(TableA.c));
                  String d = cursor.getString(cursor.getColumnIndex(TableA.d));
                  String e = cursor.getString(cursor.getColumnIndex(TableA.e));
  
                  Object record = new Object (a, b, c, d, e);             
                  list.add(record );              
              } while (cursor.moveToNext());
          } 
      } finally {
          cursor.close();
      }           
  } finally {
  
  }
  </code></pre>
  
  <p><strong>Updated</strong></p>
  
  <p>SQL query (changed column and table names. There is no influence due to renaming):</p>
  
  <pre><code>SELECT
      a ,
      b ,
      c ,
      d ,
      e
  FROM TableA
      INNER JOIN TableB ON(TableB._id=TableA.y_id)
      LEFT JOIN TableC ON(TableC._id=TableA.x_id)
  WHERE active=1 AND xxx&gt;1370090365365 AND xxx&lt;1370867965365
  ORDER BY TableA.xxx DESC
  </code></pre>
  
  <p>Like I said: this query runs as I expected and returns result in desktop SQLite client.</p>
  
  <p><strong>Updated</strong></p>
  
  <p>Besides I'm getting this kind warning despite all Cursor and SQLiteDatabase objects is wrapped by <em>try...finally</em> and closed.</p>
  
  <pre><code>W/CursorWrapperInner(10374): Cursor finalized without prior close()
  </code></pre>