Taki
Taki

Reputation: 3730

android.database.sqlite.SQLiteException: not an error (code 0 SQLITE_OK)

I'm using this library to save , retreive and delete data , but whenever i try to perform any of those operations , it throws the above mentionned error , and this is the library that i'm using

  implementation 'com.github.p32929:AndroidEasySQL-Library:1.4.1'
 private fun deleteCartDetails() {
        val easyDB = EasyDB.init(this,"ITEMS_DB")
                .setTableName("CART_TABLE")
                .addColumn(Column("item_id", *arrayOf("text","unique")))
                .addColumn(Column("item_productId", *arrayOf("text","not null")))
                .addColumn(Column("item_title", *arrayOf("text","not null")))
                .addColumn(Column("item_price", *arrayOf("text","not null")))
                .addColumn(Column("item_cost", *arrayOf("text","not null")))
                .addColumn(Column("item_quantity", *arrayOf("text","not null")))

        easyDB.deleteAllDataFromTable()
    }

any help would be appreciated guys , thank you .

Upvotes: 1

Views: 2066

Answers (1)

MikeT
MikeT

Reputation: 56943

I believe that you are missing the line that creates the table before you are trying to delete rows from the table.

That is the .doneTableColumn() which should follow the .addColumn's

So try :-

private fun deleteCartDetails() {
    val easyDB = EasyDB.init(this,"ITEMS_DB")
            .setTableName("CART_TABLE")
            .addColumn(Column("item_id", *arrayOf("text","unique")))
            .addColumn(Column("item_productId", *arrayOf("text","not null")))
            .addColumn(Column("item_title", *arrayOf("text","not null")))
            .addColumn(Column("item_price", *arrayOf("text","not null")))
            .addColumn(Column("item_cost", *arrayOf("text","not null")))
            .addColumn(Column("item_quantity", *arrayOf("text","not null")))
            .doneTableColumn() //<<<<<<<<<< ADDED

    easyDB.deleteAllDataFromTable()
}

Upvotes: 1

Related Questions