Possible Duplicate:
How to load image from url
I want to know how to load image from URL and save in local database.
Pls help me
Thanks Monali
Possible Duplicate:
How to load image from url
I want to know how to load image from URL and save in local database.
Pls help me
Thanks Monali
-You might find some help in loading the image from a URL in:
How to load an ImageView by URL in Android?
-As for saving it, this may be useful:
To do this, you should use the MediaStore API
String yourImageFilename= String.valueOf(System.currentTimeMillis()); //using this for simplicity
ContentValues cValues = new ContentValues();
cValues.put(Images.Media.TITLE, yourImageFilename);
cValues.put(Images.Media.DATE_ADDED, System.currentTimeMillis());
cValues.put(Images.Media.MIME_TYPE, "image/jpeg"); //your image type here, jpg for sample
Uri uri = context.getContentResolver().insert(Images.Media.INTERNAL_CONTENT_URI, values);
try {
OutputStream outStream = context.getContentResolver().openOutputStream(uri);
Url imageResource = new Url("your url string");
Bitmap mBitmap = BitmapFactory.decodeStream(imageResource.openStream());
mBitmap.compress(Bitmap.CompressFormat.JPEG, 90, outStream); //if you want to compress the jpg
outStream.flush();
outStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
I am assuming you mean in the local database(viewable by the gallery, if not then please edit your question to be more specific).