@Override
 public void onItemClick(AdapterView<?> l, View v, int position, long id) {
   if (l.getId() == R.id.photosGridView) {
     String clickedItem = photosGridViewContents[position];
     Intent intent = new Intent(PhotoGridActivity.this, PhotoViewerActivity.class);
     intent.putExtra(
         "filename",
         clickedItem); // use putExtra method of Intent here for passing additional information to
                       // PhotoViewerActivity
     startActivity(intent);
   }
 }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
   if (requestCode == FILECHOOSER_RESULTCODE) { // found this from StackOverflow
     if (null == mUploadMessage) return;
     Uri result = intent == null || resultCode != RESULT_OK ? null : intent.getData();
     mUploadMessage.onReceiveValue(result);
     mUploadMessage = null;
   } else {
     // -----------I wrote this code below this line----------------------------------
     jpegData = intent.getExtras().getByteArray("image");
     Bitmap img = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length);
     Drawable d = new BitmapDrawable(img);
     profilePicture.setBackground(d);
   }
 }