我正在关注@JuanSánchez 建议的答案,但我遇到了一个问题。
我的问题是ClassCastException
尝试将android.database.Cursor
对象 (c) 转换为CursorWrapper
. 更具体地说,代码行是这样的CursorWrapper cw = (CursorWrapper)c;
。
CursorWindow cursorWindow = null;
int cursorPosition = 0;
if (android.os.Build.VERSION.SDK_INT < 11) {
CursorWrapper cw = (CursorWrapper)c;
Class<?> cursorWrapper = CursorWrapper.class;
Field mCursor = null;
try {
mCursor = cursorWrapper.getDeclaredField("mCursor");
mCursor.setAccessible(true);
AbstractWindowedCursor abstractWindowedCursor = (AbstractWindowedCursor)mCursor.get(cw);
cursorWindow = abstractWindowedCursor.getWindow();
cursorPosition = abstractWindowedCursor.getPosition();
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
任何帮助我都会非常感激。