The javadocs indicate that android.database.Cursor has a getType(int) method. However, when I try to call this method, Eclipse gives me an error saying no method exists. What gives?
The javadocs indicate that android.database.Cursor has a getType(int) method. However, when I try to
Share
What version of Android are you targeting? The
getType()method applies only to v3.0 and later.EDIT: Assuming you’re targeting pre v3.0 versions of Android then a possible ‘hack’ to discover the type of each column within a table would be to query the sqlite_master table to find the CREATE data.
It’s pretty nasty but if you really need to find the type then you could extend SQLiteCursor and add your own
getType(int columnIndex)method.You could perform a one-off query to the
sqlite_mastertable when the cursor first accesses a table then parse theCREATEstatement from thesqlcolumn and store the ‘types’ in anint[].In the
getType(int columnIndex)you would simply return the value of yourint[]based oncolumnindex.As I said, bit of a hack but it would work.