Cursor.getType() for API Level <11

前端 未结 4 1043
北荒
北荒 2020-12-10 01:00

I\'m querying the CallLog content provider and need to detect the column types.

In Honeycomb and newer (API Level 11+) you can get a columns preferred data type by c

4条回答
  •  既然无缘
    2020-12-10 01:46

    There is something that may work : http://developer.android.com/reference/android/database/DatabaseUtils.html cursorRowToContentValues

    will copy the row in a ContentValues object. Then, you can call ContentValues.get(), which give you an object. you can then look at the Class of this object.

    edit

    According to the source code of DatabaseUtils, the object are either blobs or Strings.

    edit 2

    However, if your cursor is a WindowedCursor, it has methods to know the object types. (isBlob, isString, isLong...)

提交回复
热议问题