i'm trying to download images from their urls and save them in special folder and yeah i did that but my my Pictures folder doesn't appear in Gallery please any suggestion to solve this problem.
llDownloadWallpaper.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// set as wallpapers
lt.setText("Please Wait ...");
lt.setTranslationY(100);
lt.show();
Glide.with(getApplication())
.load(url)
.asBitmap()
.toBytes(Bitmap.CompressFormat.JPEG, 80)
.into(new SimpleTarget<byte[]>() {
@Override public void onResourceReady(final byte[] resource, GlideAnimation<? super byte[]> glideAnimation) {
new AsyncTask<Void, Void, Void>() {
@Override protected Void doInBackground(Void... params) {
File sdcard = Environment.getExternalStorageDirectory();
File file = new File( sdcard+ "/ARTApp/"+"ART_"+System.currentTimeMillis()+".jpg");
File dir = file.getParentFile();
try {
if (!dir.mkdirs() && (!dir.exists() || !dir.isDirectory())) {
throw new IOException("Cannot ensure parent directory for file " + file);
}
BufferedOutputStream s = new BufferedOutputStream(new FileOutputStream(file));
s.write(resource);
s.flush();
s.close();
} catch (IOException e) {
e.printStackTrace();
lt.error();
}
return null;
}
}.execute();
lt.success();
}
})
;
}
});
}