title: Android: BitmapFactory issue
body: <p>Good Day 
  I'm trying to display captured image in gridview as well save it in Sqlite Database..in the logcat appear this </p>
  
  <blockquote>
    <p>E/BitmapFactory: Unable to decode stream:
    java.lang.NullPointerException W/System.err:
    java.lang.NullPointerException W/System.err:  at
    .CameraFragment.previewCapturedImage(CameraFragment.java:259
    W/System.err:  at
    CameraFragment.onActivityResult(CameraFragment.java:215)</p>
  </blockquote>
  
  <p><strong>which point to this line in my code</strong> </p>
  
  <pre><code>bitmap.compress(Bitmap.CompressFormat.PNG, 0, stream);
  </code></pre>
  
  <p><strong>here is the code</strong></p>
  
  <pre><code> @Override
          public View onCreateView(LayoutInflater inflater,  ViewGroup container,  Bundle savedInstanceState) {
              View view = inflater.inflate(R.layout.fragment_camera, container, false);
  
              final DatabaseAdapter DBadapter = new DatabaseAdapter(getActivity());
              DBadapter.open();
              myLists = new ArrayList&lt;Images&gt;();
              myLists = DBadapter.getImagesList();
              // imageView = (ImageView) view.findViewById(R.id.imageListView);
              Button myButton = (Button) view.findViewById(R.id.camerabutton);
              myButton.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                     // fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);// create a file to save the image
                     // intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
                      startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE); // start the image capture Intent
  
  
                  }
              });
              adapter = new ImageListAdapter(getActivity(), R.layout.img_list_view, myLists);
              myGridView = (GridView) view.findViewById(R.id.gridView);
              myGridView.setAdapter(adapter);
  
   private File createImageFile() throws IOException {
          // Create an image file name
          String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
          String imageFileName = "JPEG_" + timeStamp + "_";
          File storageDir = Environment.getExternalStoragePublicDirectory(
                  Environment.DIRECTORY_PICTURES);
          File image = File.createTempFile(
                  imageFileName,  /* prefix */
                  ".jpg",         /* suffix */
                  storageDir      /* directory */
          );
  
          // Save a file: path for use with ACTION_VIEW intents
          mCurrentPhotoPath = "file:" + image.getAbsolutePath();
          return image;
      }
          }
  
  
          @Override
              public void onActivityResult(int requestCode, int resultCode, Intent data) {
                  super.onActivityResult(requestCode, resultCode, data);
                if (requestCode==CAMERA_CAPTURE_IMAGE_REQUEST_CODE&amp;&amp;resultCode == Activity.RESULT_OK){
  
                             previewCapturedImage();
  
                     Toast.makeText(getActivity(), "InvoiceFile saved successfully", Toast.LENGTH_LONG).show();
  
                  }
                         else if (resultCode == getActivity().RESULT_CANCELED) {
                             // user cancelled Image capture
                             Toast.makeText(getActivity(), "User cancelled image capture", Toast.LENGTH_SHORT)
                                     .show();}
                         else {
                             // failed to capture image
  
                             Toast.makeText(getActivity(), "Sorry! Failed to capture image", Toast.LENGTH_SHORT)
                                     .show();
                         }}
           private void previewCapturedImage() {
  
  
          BitmapFactory.Options bmOptions = new BitmapFactory.Options();
           ByteArrayOutputStream stream = new ByteArrayOutputStream();
                      Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
          bitmap.compress(Bitmap.CompressFormat.PNG, 0, stream);
  
                      byte[] byte_arr = stream.toByteArray();
                      images.setImageBlob(byte_arr);
                      // Add Image Path To List
                      myLists.add(images);
                      // Refresh Gridview Image Thumbnails
  
                      adapter.notifyDataSetChanged();
                      DBadapter.insertImage(images);
  
                  }
  </code></pre>
  
  <p><strong>any Help will be appreciate</strong> </p>