Since I am sending the image to Parse.com, I have to convert it into byte Array. My first approach is to select an image from gallery and convert it to byte array as follows:
 @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
             mMediaUri = data.getData();
            String[] filePathColumn = { MediaStore.Images.Media.DATA };
            Cursor cursor = getContentResolver().query(mMediaUri,
                    filePathColumn, null, null, null);
            cursor.moveToFirst();
            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            picturePath = cursor.getString(columnIndex);
            cursor.close();
           // ImageView imageView = (ImageView) findViewById(R.id.imgView);
            propertyImage.setImageBitmap(BitmapFactory.decodeFile(picturePath));
            Bitmap bmp = BitmapFactory.decodeFile(picturePath);
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
            byteArray = stream.toByteArray();
        }
The above code works fine and the image is successfully stored to parse. Now, I when No image is selected, The App crashes. Obviously bcoz, no data is sent and parse exception is raised.
Now, I want to set a default image, that is in my drawable folder to go to parse, in case -no image is selected from the gallery, so that parse operations are not disturbed with null data.
My approach was to set the default image in the starting itself:
propertyImage=(ImageView)findViewById(R.id.imageViewOfImage);
        propertyImage.setImageResource(R.drawable.blank_image);
Now, how would I convert this default image to a ByteArray, so that it can be sent to parse?
Thanks and Regards