How Can I convert an imageview to byte array in Android Studio?
<p>My goal is to get a picture selected by the user and populate an image view with it. Then, on clicking a button, that image will be sent to a Parse database. I know I have to convert the imageview to byte array, but Doesn't seem to work.</p>

<p>Any help will be highly appreciated. 
here's my code:</p>

<pre><code> //send the imageviwew to parse database

 public void sendToParseBtn (View view){
     Bitmap bitmapImage = findViewById (R.id.imageView);
     ImageView imageView = (ImageView) findViewById(R.id.imageView);
     imageView.setImageBitmap(bitmapImage);

     ByteArrayOutputStream stream = new ByteArrayOutputStream();
     bitmapImage.compress(Bitmap.CompressFormat.JPEG, 40, stream);

     byte[] byteArray = stream.toByteArray();

     ParseFile file = new ParseFile("an.jpg",byteArray);
     ParseObject object = new ParseObject("MyParseObject");
     object.put("imageFile", file);

     object.saveInBackground();
 }
</code></pre>