jeudi 28 mai 2015

Inserting boolean value in SQLite DB

I have read that SQLite doesnot support boolean datatype instead we need to use Integer 1(true) and 0(false). So i have Used the Integer and it's getting inserted correctly but when i am retreiving the rows based on the comparision i am not getting the rows. I don't understand why.

The snippets are like this:

private static final String TABLE_NAME = "Shipyard";
private static final String SHIP_TYPE = "shipType";
private static final String SHIP_STATUS_TYPE = "shipStatusType";

 String selectQuery = "SELECT  * FROM " + TABLE_NAME+ " WHERE "+SHIP_TYPE+ " = "+ "'active' AND "+SHIP_STATUS_TYPE+" = 1";

Here the SHIP_STATUS_TYPE should be equal to 1 which is boolean in my case . But I am getting zero rows. But in mine Db there is column with shipStatusType = 1

I am creating table like this

String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " ("
                + SHIP_ID + " TEXT PRIMARY KEY," + SHIP_TITLE + " TEXT,"
                +SHIP_STATUS_TYPE+" INTEGER)";

Here I have set SHIP_STATUS_TYPE data type as INTEGER which is kind of boolean in my case(0\1)

Now the point is I am comparing it wrong or some else thing is there

Aucun commentaire:

Enregistrer un commentaire