title: Using SQLite Trigger to update "LastModified" field
body: <p>This might be more of a design question, but here goes. I'm writing an Android app that uses a local SQLite database (with multiple tables) that syncs with a MySQL database every now-and-then. I only want to update modified rows in my database. To do this, I'm adding a column "<code>last_modified</code>" to each row that indicates the time when that row was added/updated/replaced/etc.</p>
  
  <p>I'm new to database operations, but I've seen that a Trigger might be the best way to do this. I have a couple questions relating to Triggers, SQLite, and Android.</p>
  
  <p>I've read this link: <a href="https://stackoverflow.com/questions/6578439/on-update-current-timestamp-with-sqlite">on update current_timestamp with SQLite</a> It basically says that I'm using the right approach. My questions are:</p>
  
  <ol>
  <li>Where should I put the <code>db.execSQL("CREATE TRIGGER...")</code> statement? Before or after I create the tables?</li>
  <li>Can I use the same Trigger for every table in my database? i.e, can the Trigger automatically detect which table and row is being updated/inserted/replaced/etc. and notify to set that row's "<code>last_modified</code>" field, or do I have to create a separate Trigger for each table?</li>
  <li>Since I'm quite new to database operations, could you provide an example Android Trigger statement that performs the above behavior, or provide a resource to an example?</li>
  </ol>
  
  <p>Or if Triggers are a bad idea, are there any better alternatives?</p>
  
  <p>Thank you.</p>