Note that there are some explanatory texts on larger screens.

plurals
  1. POError inserting a record in SQLite DB
    primarykey
    data
    text
    <pre><code>public class DBCreation extends SQLiteOpenHelper { Context context; public DBCreation(Context context) { super(context, "LBRDatabase", null, 1); } @Override public void onCreate(SQLiteDatabase db) throws SQLException { db.execSQL("create table Reminders(id integer primary key autoincrement,description text,address text not null,latitude double not null,longitude double not null,radius text,reminderdate text,remindertime text);"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { try { db.execSQL("drop table if exists Reminders "); onCreate(db); } catch (Exception e) { Toast.makeText(context, ""+e, Toast.LENGTH_LONG).show(); } } } </code></pre> <p>What is the problem with this code? It is giving me the following error?</p> <pre><code>06-18 08:54:30.843: E/Database(6452): Error inserting Reminders 06-18 08:54:30.843: E/Database(6452): android.database.sqlite.SQLiteException: no such table: Reminders: , while compiling: INSERT INTO Reminders(radius, longitude, latitude, reminderdate, address, description, remindertime) VALUES(?, ?, ?, ?, ?, ?, ?); </code></pre> <p>The table is getting created.The order of insertion is also not proper.It is first taking radius then longitude, then longitude which is not the order in which i created the table.</p> <pre><code>public class DBOperations { Context context; SQLiteDatabase db; DBCreation createdb; public DBOperations(Context context) { this.context = context; createdb = new DBCreation(context); } public DBCreation OpenDB() throws SQLException { db = createdb.getWritableDatabase(); return createdb; } public void CloseDB() { db.close(); } public long addReminder(String description,String address,double latitude,double longitude,String radius,String date,String time) { ContentValues cv = new ContentValues(); cv.put("description", description); cv.put("address", address); cv.put("latitude", latitude); cv.put("longitude", longitude); cv.put("radius", radius); cv.put("reminderdate", date); cv.put("remindertime", time); return db.insert("Reminders", null, cv); } public long deleteReminder(int id) { return db.delete("Reminders", "_ID="+id, null); } public long updateReminder(int id,String desc,String addr,double lat,double lon,int radius,String date,String time) { ContentValues cv = new ContentValues(); cv.put("description", desc); cv.put("address", addr); cv.put("latitude", lat); cv.put("longitude", lon); cv.put("radius", radius); cv.put("reminderdate", date); cv.put("remindertime", time); return db.update("Reminders", cv, "_ID="+id, null); } public Cursor showReminders() { Cursor c = db.query("Reminders", null, null , null, null, null, null); if(c!=null) { return c; } else { return null; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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