title: How to delete old rows from sqlite database on android?
body: <p>I have a parameter, where user can choose for which period of time data should be stored.
  I read it in <code>days</code> variable. Date and time, when record was added to the database is stored in <code>KEY_DATE_ADDED</code>, it is created like:</p>
  
  <pre><code>SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  // sql date format
  Date date = new Date();
  initialValues.put(KEY_DATE_ADDED, dateFormat.format(date));
  </code></pre>
  
  <p>Then I do the following:</p>
  
  <pre><code>mDb.delete(DATABASE_TABLE, 
             "date(now) &gt; date(" + KEY_DATE_ADDED + ",+" + days + " days)",
             null);
  </code></pre>
  
  <p>and it doesn't work. Actual query (where part) looks like:</p>
  
  <blockquote>
    <p>WHERE date(now) > date(date_added,+10
    days)</p>
  </blockquote>
  
  <p>What is incorrect here? Looks like instead of <code>date_added</code> something else should be here.
  I wanted to use <a href="http://www.sqlite.org/lang_datefunc.html" rel="nofollow">SQL data formatting</a> to avoid re-formatting dates several times.</p>
  
  <p>Is there any GUI for Android database to test SQL queries on the actual data?</p>