Cursor.getType() returns value of 5 (undocumented)


I encountered a problem where calling Cursor.getType() for a column returns a type value of 5. The documented FIELD_TYPE values in Cursor class only contain values 0 to 4. The actual SQL datatype for the column is TEXT. Weird thing is that the same table contains a couple of other TEXT fields that are identified as type value 3.

Inserting data to table works fine, but the problem arises when I run a SELECT query.

Any ideas why this is happening? Also any directions or links any to related or similar issues is appreciated.

(I’m developing on Android, API level 18)

Hello @FrankX

Are you able to reproduce this with a unit test within the SQLCipher for Android test suite? We already have a test around the 5 documented types to be returned here.


The test application gives me this error

E/AndroidRuntime(26209): Caused by: java.lang.ClassNotFoundException: Didn’t find class “net.sqlcipher.database.SQLiteDatabase” on path: DexPathList[[zip file “/data/app/net.zetetic-2/base.apk”],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

I did run some more tests and it appears that it returns the number 5 as column type if all the fields on that column have null values. E.g.

“foo”, “bar”, null, 1
"foo", “bar”, null, 2
"foo", “bar”, null, 3

then the Cursor.getType() returns 3 for the first and the second column column, 5 for the third column and 1 for the fourth column.

Hello @FrankX

The test application should open properly within IntelliJ, can you give that a try and build it? You can load the test application from either the included project file, or the pom.xml. Can you then create a test that reproduces the error?

I’ve got the same trouble, getType returns 5, in my query i have only sum(…) and count(*) functions.

  • yes it seems that null values cause getType to return 5.