我正在查询MediaStore.Images.Media.EXTERNAL_CONTENT_URI
并且查询工作正常。我能够从具有常数的每一列中获取数据,例如:
currentImage.ImageUrl = imagecursor.getString(imagecursor.getColumnIndex(MediaStore.Images.Media.DATA));
currentImage.Lat = imagecursor.getString(imagecursor.getColumnIndex(MediaStore.Images.Media.LATITUDE));
currentImage.Long = imagecursor.getString(imagecursor.getColumnIndex(MediaStore.Images.Media.LONGITUDE));
宽度/高度列没有常数(no MediaStore.Images.Media.WIDTH
),所以我尝试使用imagecursor.getLong(imagecursor.getColumnIndex("width"));
.
尝试使用 getLong、getString、getInt... 什么都没有 - 总是同样的崩溃。
这是堆栈:
02-22 19:38:26.242: E/AndroidRuntime(1607): FATAL EXCEPTION: main
02-22 19:38:26.242: E/AndroidRuntime(1607): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.MEDIA_SCANNER_FINISHED dat=file:///mnt/sdcard flg=0x10 } in com.Activity.android.chat.service.ChatService$ChatServiceReceiver@415b26c0
02-22 19:38:26.242: E/AndroidRuntime(1607): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:737)
02-22 19:38:26.242: E/AndroidRuntime(1607): at android.os.Handler.handleCallback(Handler.java:605)
02-22 19:38:26.242: E/AndroidRuntime(1607): at android.os.Handler.dispatchMessage(Handler.java:92)
02-22 19:38:26.242: E/AndroidRuntime(1607): at android.os.Looper.loop(Looper.java:137)
02-22 19:38:26.242: E/AndroidRuntime(1607): at android.app.ActivityThread.main(ActivityThread.java:4424)
02-22 19:38:26.242: E/AndroidRuntime(1607): at java.lang.reflect.Method.invokeNative(Native Method)
02-22 19:38:26.242: E/AndroidRuntime(1607): at java.lang.reflect.Method.invoke(Method.java:511)
02-22 19:38:26.242: E/AndroidRuntime(1607): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-22 19:38:26.242: E/AndroidRuntime(1607): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-22 19:38:26.242: E/AndroidRuntime(1607): at dalvik.system.NativeStart.main(Native Method)
02-22 19:38:26.242: E/AndroidRuntime(1607): Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
02-22 19:38:26.242: E/AndroidRuntime(1607): at android.database.CursorWindow.nativeGetLong(Native Method)
02-22 19:38:26.242: E/AndroidRuntime(1607): at android.database.CursorWindow.getLong(CursorWindow.java:515)
02-22 19:38:26.242: E/AndroidRuntime(1607): at android.database.CursorWindow.getInt(CursorWindow.java:582)
02-22 19:38:26.242: E/AndroidRuntime(1607): at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:69)
02-22 19:38:26.242: E/AndroidRuntime(1607): at android.database.CursorWrapper.getInt(CursorWrapper.java:102)
02-22 19:38:26.242: E/AndroidRuntime(1607): at com.Activity.android.chat.service.ChatService.getUserImages(ChatService.java:251)
02-22 19:38:26.242: E/AndroidRuntime(1607): at com.Activity.android.chat.service.ChatService.access$1(ChatService.java:209)
02-22 19:38:26.242: E/AndroidRuntime(1607): at com.Activity.android.chat.service.ChatService$ChatServiceReceiver.onReceive(ChatService.java:204)
02-22 19:38:26.242: E/AndroidRuntime(1607): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:728)
02-22 19:38:26.242: E/AndroidRuntime(1607): ... 9 more
将不胜感激任何帮助...不知道我还能尝试什么。
谢谢!