我有一个程序,允许用户从图库中选择图像,将其保存在数据库中并在屏幕上显示。这适用于大多数图像,但对于某些图像,应用程序崩溃。 Logcat中没有错误消息。但是当我重新启动应用程序时,我收到一条错误消息:
无法从CursorWindow读取第0行第1列。在从中访问数据之前,请确保Cursor已正确初始化。
(在ANDROID SDK 24上测试)
new AlertDialog.Builder(this).setTitle("Take or Pick?").setMessage("Choose to click a new picture or choose from existing").
setNegativeButton("CHOOSE PHOTO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent i = new Intent(
Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, REQUEST_IMAGE_PICKER);
}
}).create().show();
if (requestCode == REQUEST_IMAGE_PICKER && resultCode == RESULT_OK && null != data) {
Uri selectedImage = data.getData();
Bitmap bmp= null;
try { //GET BITMAP FROM URI , TRY CATCH USED TO TACKLE
bmp = BitmapFactory.decodeStream(getContentResolver().openInputStream(selectedImage)); // IO STREAM FILE NOT FOUND ERROR
} catch (FileNotFoundException e) {
e.printStackTrace();
}
if(cameraTeamStatus==1) {
img1.setImageBitmap(bmp); //SET IMAGE
image1_to_save = convertToBlob(bmp); //CONVERT TO BLOB
}