Hi can any one help how to save the images into SD card which i can able to retrieve from the URL link.
+1
A:
First you must make sure your application has permission to write to the sdcard. To do this you need to add the uses permission write external storage in your applications manifest file. See Setting Android Permissions
Then you can you can download the URL to a file on the sdcard. A simple way is:
URL url = new URL ("file://some/path/anImage.png");
InputStream input = url.openStream();
try {
OutputStream output = new FileOutputStream ("/sdcard/myImage.png");
try {
byte[] buffer = new byte[aReasonableSize];
int bytesRead = 0;
while ((bytesRead = input.read(buffer, 0, buffer.length)) >= 0) {
output.write(buffer, 0, buffer.length);
}
} finally {
output.close();
}
} finally {
input.close();
}
Akusete
2010-07-21 07:04:06
+1
A:
Hi,
An excellent example can be found in the latest post on Android developer's blog.
ognian
2010-07-21 10:05:35