title: There is no error but still can't change phone contact image
body: <p>I'm quit scared with this application. I'm developing an application that changes the contact photo with from image-view. It doesn't generate any error but does not even change contact image. I have a doubt, if it's the OnActivityResult() method. Please correct me on that. Here is the code of OnActivityResult() method.</p>
  
  <pre><code>    if (resultCode == Activity.RESULT_OK) { 
          switch (requestCode) {
          case IMAGE_PICK:    
              this.imageFromGallery(resultCode, data);
              break;
          case IMAGE_CAPTURE:
              this.imageFromCamera(resultCode, data);
              break;
           case PICK_PHOTO:
                  if(resultCode == RESULT_OK){ 
  
                      // Getting the uri of the picked photo
                      Uri updateImageView = data.getData();
  
                      InputStream imageStream = null;
                      try {
                          // Getting InputStream of the selected image
                          imageStream = getContentResolver().openInputStream(updateImageView);
                      } catch (FileNotFoundException e) {
                          e.printStackTrace();
                      }
  
                      // Creating bitmap of the selected image from its inputstream
                      image = BitmapFactory.decodeStream(imageStream);
  
                      // Getting reference to ImageView
                     // ImageButton ibPhoto = (ImageButton) findViewById(R.id.photo);
  
                      // Setting Bitmap to ImageButton
                      photo.setImageBitmap(image);
                  } 
                  break;
          default:
              break;
          }
      }
  }
  </code></pre>
  
  <blockquote>
    <p>also here is my onClick() code.</p>
  </blockquote>
  
  <pre><code> save.setOnClickListener(new View.OnClickListener() 
      {
  
          @Override
          public void onClick(View arg0)
          {
  
              ArrayList&lt;ContentProviderOperation&gt; ops =
                      new ArrayList&lt;ContentProviderOperation&gt;();
  
               int position=getIntent().getExtras().getInt("bmp");
              int po=ops.size();
              ByteArrayOutputStream stream = new ByteArrayOutputStream();
  
                if(image!=null)
                { // If an image is selected successfully
                    image.compress(Bitmap.CompressFormat.PNG , 100, stream);
  
  
  
                 //   ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    image.compress(Bitmap.CompressFormat.PNG , 75, stream);
  
                    ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
                               .withValue(ContactsContract.Data.RAW_CONTACT_ID, position) // here position is _ID where I'm inserting image
                               .withValue(ContactsContract.Data.IS_SUPER_PRIMARY, 1)
                               .withValue(ContactsContract.Data.MIMETYPE,ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE)
                               .withValue(ContactsContract.CommonDataKinds.Photo.PHOTO,stream.toByteArray())
                               .build());
  
                        try {
                             stream.flush();
  
                            } catch (IOException e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                            }      
  
                }  
                else
                {
                    Log.d("Image Null", "True");
                }
                try{
  
                    // Executing all the insert operations as a single database transaction
                    getContentResolver().applyBatch(ContactsContract.AUTHORITY,ops);
                    Toast.makeText(getBaseContext(), "Contact Image change successfully", Toast.LENGTH_SHORT).show();
                }
          catch (RemoteException e) {
                    e.printStackTrace();
  
                }catch (OperationApplicationException e) {
                    e.printStackTrace();
                }             
              }       });
  </code></pre>