This is the code that save image in very low resolution.The image from url is too big but when I save image through this code it reduce size and resolution of image
private void saveImage(final String uri) throws IOException,
IllegalStateException {
URL url = new URL(uri);
InputStream input = url.openStream();
File storagePath = Environment.getExternalStorageDirectory();
OutputStream output = new FileOutputStream(storagePath + "/myImage.png");
try {
byte[] buffer = new byte[2048];
int bytesRead = 0;
while ((bytesRead = input.read(buffer, 0, buffer.length)) >= 0) {
output.write(buffer, 0, bytesRead);
}
} finally {
output.close();
}