title: How to secure the synced data in my Android app?
body: <p>I'm building an Android app which contains an SQLite db with very sensitive data. Since anyone with physical access to the device could copy the database I thought of a couple solutions to safeguard the data in the database. We can of course encrypt it before entering it into the DB, but since this would inhibit the possibility to actually query the database, it would effectively make the DB useless. Plus: if we store the key within the app, it would make it very easy to retrieve the key as well, and with that the encryption would be pointless. </p>
  
  <p>So we sync all the data with the server upon login, and after that there are a couple options:</p>
  
  <ol>
  <li>Deleting the whole database in the onStop() method. I think that would be pretty safe, except for when the app crashes I suppose it doesn't call the onStop() method. Since you could manually destroy the process I suppose that a person with physical access to the device, would still be able to access the database. Right?</li>
  <li>Use an in-memory SQLite database. According to this SO answer though "<em>Every new connection to an in-memory database creates a new, empty database.</em>". This means that you cannot share it amongst Activities. </li>
  <li>Store the synced data in a couple Java Lists/Arrays and getting all the information from them. The problem is that these lists only exist in one Activity. To solve this I thought of creating the full app within one fragment. I haven't started trying this yet, but it doesn't seem like the normal way to do this either.</li>
  </ol>
  
  <p>Does anybody know if any of these ideas make sense, and more importantly, if there isn't a better/more convenient way of saving data securely across the apps activities? All tips are welcome!</p>