Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need a space in the SQL in your <code>onUpgrade</code> method:</p> <pre><code>@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub db.execSQL("DROP TABLE IF EXISTS "+TABLE_CONTACTS); onCreate(db); } </code></pre> <p>Currently the executed SQL is: <code>DROP TABLE IF EXISTScontacts</code></p> <p>It needs to be: <code>DROP TABLE IF EXISTS contacts</code></p> <p>This also applies to a few places in your <code>onCreate</code> method:</p> <pre><code>@Override public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub String CREATE_TABLE_CONTACTS="CREATE TABLE "+TABLE_CONTACTS+"("+KEY_ID+" INTEGER PRIMARY KEY,"+KEY_NAME+" TEXT,"+KEY_NUMBER+" TEXT"+")"; db.execSQL(CREATE_TABLE_CONTACTS); } </code></pre> <p>Something which helps me track down errors like this is to add a try/catch block and throw your own exception which includes the generated SQL, e.g.:</p> <pre><code> @Override public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub String CREATE_TABLE_CONTACTS="CREATE TABLE "+TABLE_CONTACTS+"("+KEY_ID+" INTEGER PRIMARY KEY,"+KEY_NAME+" TEXT,"+KEY_NUMBER+" TEXT"+")"; try { db.execSQL(CREATE_TABLE_CONTACTS); } catch (SQLException sqlException) { throw new SQLException("Error executing SQL: '" + CREATE_TABLE_CONTACTS + "', message: " + sqlException.getMessage(), sqlException); } } </code></pre> <p>This allows you to see the error message as well as the SQL which caused it. If you do this it's recommended to create your own <code>execSQL</code> method which includes this code. You could even create your own wrapper around <code>SQLiteDatabase</code> and add this logic to your own overridden <code>execSQL</code>.</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. This table or related slice is empty.
    1. 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