i'm trying to add Download Feature to my application i 'm using Glide Library to downlaod the pictures from their url This is the code from which I save an picture in device storage but not working well works fine with android 5.0.1 and 6.0.1 But in another Android version does not work well
Toast.makeText(Pop.this, "Please wait ...", Toast.LENGTH_LONG).show();
new AsyncTask<FutureTarget<Bitmap>, Void, Bitmap>() {
@Override protected Bitmap doInBackground(FutureTarget<Bitmap>... params) {
try {
return params[0].get();
// get needs to be called on background thread
} catch (Exception ex) {
return null;
}
}
@Override protected void onPostExecute(Bitmap bitmap) {
if(bitmap == null) return;
MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "Art_"+System.currentTimeMillis(), "Beschrijving");
}
}.execute(Glide.with(getApplicationContext()).load(url).asBitmap().diskCacheStrategy(DiskCacheStrategy.SOURCE).into(width, height));
please help me
Basing on Akshay Nandwana answer I used that code to write to internal memory:
And here is the
write
method:1.Permissions in manifest file
2.Glide to download the image as a bitmap
3. Save the bitmap into your memory