title: Android SQLite query rows from bottom to top with timestamp to equal current date
body: <p>I am using SQLite for my app and I kind of have a large database. The database has 3 columns:</p>
  
  <p>id(int auto incerement)|timestamp(int)|value(string)</p>
  
  <p>I want to have the latest records, which have timestamp (millisec) of the current day.</p>
  
  <p>At the I have a code to query all the records in the table, but it is awfully slow:</p>
  
  <pre><code>public List&lt;PhysicalActivity&gt; getAllPhysicalActivities(){
      List&lt;PhysicalActivity&gt; all = new ArrayList&lt;PhysicalActivity&gt;();
  
      Cursor cursor = mDatabase.query(PhysicalActivityDatabaseHelper.TABLE_NAME, mColumns
              , null, null, null, null, null);
  
      cursor.moveToFirst();
  
      while(!cursor.isAfterLast()) {
          PhysicalActivity pa = cursorToPhysicalActivity(cursor);
          all.add(pa);
          cursor.moveToNext();
      }
  
      cursor.close();
      return all;
  }
  </code></pre>
  
  <p>I want to do <code>ORDER BY id DESC</code> as you would do in MySQL...I need to have something like this code:</p>
  
  <pre><code>public List&lt;PhysicalActivity&gt; getPhysicalActivitiesForDate(Date date){
      List&lt;PhysicalActivity&gt; activities = new ArrayList&lt;PhysicalActivity&gt;();
  
      Cursor cursor = mDatabase.query(PhysicalActivityDatabaseHelper.TABLE_NAME, mColumns
              , null, null, null, null, "ORDERBY " + PhysicalActivityDatabaseHelper.COLUMN_ID + 
      " DESC");
  
      cursor.moveToFirst();
      while(!cursor.isAfterLast()){
          PhysicalActivity pa = cursorToPhysicalActivity(cursor);
          Date d = new Date(pa.getTimestamp());
          if(d.getDay() == date.getDay()){
              activities.add(pa);
          }
          cursor.moveToNext();
      }
  
      cursor.close();
      return activities;
  }
  </code></pre>
  
  <p>Another problem is that <code>getDay()</code> method is deprecated...what should I replace with that to have the same effect (compare the day the row's timestamp represents to the day in the date that passed as an argument).</p>