Is there type Long in SQLite? Is there type Long in SQLite? sqlite sqlite

Is there type Long in SQLite?


From the SQLite docs

INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.

Since long is 8 byte and INTEGER can also save values of 8 bytes, you can use INTEGER.


Create the column as an INTEGER type:

db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_A + "("                + KEY + " INTEGER" + ")");

Put the long value in INTEGER column:

contentValues.put(KEY, object.getLongValue());db.insert(TABLE_A, null, contentValues);

Important: retrieve the value from cursor as LONG

Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_A, null);long value = cursor.getLong(0);


I don't think there is type long. Either you can use INTEGER (or) Numeric. Here is link with supported data types http://www.sqlite.org/datatype3.html