Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since it looks like your problem is that the user is deleting your database, just make sure to catch exceptions when you open it (or access it ... wherever you're getting the exception):</p> <pre class="lang-java prettyprint-override"><code>try { URI uri = URI.create("file:///SDCard/Databases/database1.db"); sqliteDB = DatabaseFactory.open(myURI); Statement st = sqliteDB.createStatement( "CREATE TABLE 'Employee' ( " + "'Name' TEXT, " + "'Age' INTEGER )" ); st.prepare(); st.execute(); } catch ( DatabaseException e ) { System.out.println( e.getMessage() ); // TODO: decide if you want to create a new database here, or // alert the user if the SDCard is not available } </code></pre> <p>Note that even though it's probably unusual for a user to <strong>delete</strong> a private file that your app creates, it's perfectly normal for the SDCard to be unavailable because the device is connected to a PC via USB. So, you really should always be testing for this condition (file open error).</p> <p><a href="https://stackoverflow.com/a/9272878/119114">See this answer regarding checking for SDCard availability</a>.</p> <p>Also, <a href="http://docs.blackberry.com/en/developers/deliverables/17952/SQLite_database_files_1219778_11.jsp" rel="nofollow noreferrer">read this about SQLite db storage locations</a>, and make sure to <a href="https://stackoverflow.com/a/4451954/119114">review this answer by Michael Donohue</a> about eMMC storage.</p> <hr> <h2>Update: SQLite Corruption</h2> <p><a href="http://www.sqlite.org/howtocorrupt.html" rel="nofollow noreferrer">See this link describing the many ways SQLite databases can be corrupted</a>. It definitely sounded to me like maybe the .db file was deleted, but not the journal / wal file. If that was it, you could try deleting <code>database1*</code> programmatically before you create <code>database1.db</code>. But, your comments seem to suggest that it was something else. Perhaps you could look into the file locking failure modes, too.</p> <p>If you are desperate, you might try changing your code to use a different name (e.g. <code>database2</code>, <code>database3</code>) each time you create a new db, to make sure you're not getting artifacts from the previous db.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload