Ketai library SQLite - can't insert into DB

edited January 2 in Android Mode

I am following the example at Ketai to insert a new row into an existing SQLite database. I am using a simple SQL insert statement. The println statements at the bottom from a SELECT statement suggests that everything works - I can see new rows being added to the DB. However when I go into the database itself the rows are NOT being written. Is there something obvious I am missing?

I am running this via an Android Emulator from the Processing IDE. I am beginning to suspect something to do with the emulator (or some permission thing?) as the code seems fine .... ?


class DB {
  KetaiSQLite db;
  DB(PApplet p) {
    if (KetaiSQLite.load(p, "diaryDB.db", "diaryDB")) {
      println("loaded db file");
    db = new KetaiSQLite(p,"diaryDB");

  void write(String s) {
    if (db.connect()) {
      String query = "INSERT INTO DIARY VALUES(NULL,\""+s+"\",1)";    
      if (!db.execute(query)) {
        println("error w/sql insert");
      println("data count for data table after insert: "+db.getRecordCount("DIARY"));
      db.query( "SELECT * FROM DIARY" );

      while ( ())
        print( db.getInt("DIARY_ID") );
        print( "\t"+db.getString("TEXT_ENTRY") );
    } else {
      println("db not connected");


  • Answer ✓

    Never mind, I created a db within the code and its now working.

Sign In or Register to comment.