title: Android sqlite - cursor count not 0 on empty table
body: <p>I have the following code in a bigger project:</p>
  
  <pre><code>final class DBlifetimeStatisticsHandler{ //implements DBvalueHandler&lt;Cyclist, Double&gt;{
  
  private  final String TAG = getClass().getName();
  private static final boolean debug = true;
  
  private final DBminMaxAvgHandler dbMinMaxAvgHandler = new DBminMaxAvgHandler();
  
  // table name
  private static final String TABLE_LIFETIME_STATISTICS = "lifetime_statistics";
  
  // column names
  private static final String KEY_LIFETIME_STATISTICS_ID = "lifetime_statistics_id";
  private static final String KEY_MIN_MAX_AVG = "min_max_avg";
  
  // table create statement
  private static final String CREATE_TABLE = "CREATE TABLE "
          + TABLE_LIFETIME_STATISTICS + "(" 
          + KEY_LIFETIME_STATISTICS_ID + " LONG PRIMARY KEY NOT NULL," 
          + KEY_MIN_MAX_AVG   + " LONG"
          + ")";
  
  public void onCreateTable(SQLiteDatabase db) {
      db.execSQL(CREATE_TABLE);
  }
  
  public void onUpgrade(SQLiteDatabase db) {
      db.execSQL("DROP TABLE IF EXISTS " + TABLE_LIFETIME_STATISTICS);
      onCreateTable(db);
  }
  
  public long addValue(SQLiteDatabase db, Statistics Statistics ) {
      ContentValues values = new ContentValues();
  
      long ID = getLatestID(db)+1;
  
      values.put(KEY_STATISTICS_ID, ID);
  
      ... //not important to the question
  
  }
  
  private long getLatestID(SQLiteDatabase db){
      String selectQuery = "SELECT  MAX(" + KEY_STATISTICS_ID +") FROM " + TABLE_STATISTICS;
  
      Cursor c = db.rawQuery(selectQuery, null);
  
      c.moveToFirst();
      int id = 0;
      Log.e("count", String.valueOf(c.getCount()));
  
      if (c.moveToFirst()){
         ...
      }
  
      return id;
  }
  }
  </code></pre>
  
  <p>After I updated the table it is created again. So when I try to add a new value I had problems cause it always jumped into the if clause because <code>c.moveToFirst()</code> always returned true. </p>
  
  <p>So I tried to tried to check if <code>c.getCount()</code> would return true but sadly it does always return 1. So the question is: Why would it return 1 on an empty table? (I do use Questoid SQLite Browser and the table is really empty)</p>