I’d like to use SQLiteCursor class to fetch data (not using Cursor class). This is because I need access to methods like isBoolean or isInteger and so on. They are inherited from AbstractWindowedCursor and implemented by this class which is not the case with Cursor.
I’m writing against API 7 and cannot switch to API 11 or above to use getType method (this is not my project and this are the requirements).
The problem is that I cannot create an instance of this class like a normal cursor. How is it done? I’ve tried casting it:
SQLiteCursor cursor = (SQLiteCursor)mDbHelper.getWritableDatabase().rawQuery(query,null);
but all I get is a ClassCastException. Documentation states that SQLiteCursor is “A Cursor implementation that exposes results from a query on a SQLiteDatabase”. So how can I get it if SQLiteDatabases rawQuery and query methods all return Cursor which cannot be cast?
I really need to somehow get the type of data in columns, so I know how to cast them (I never a priori know them, because all the tables are very generic). Is there a simple way to get to this methods or should I make some workaround?
Thanks for any suggestions,
kajman
Try to use like below