سلام خسته نباشید دوستان من از کد زیر برای ذخیره عکس توی گوشی استفاده کردم ولی متاسفانه عکس ای ذخیره شده توی گالری نشون داده نمیشه اگر میشه لطفا راهنماییم کنید.
class DownloadFileFromURL extends AsyncTask<String, Integer, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
showDialog(progress_bar_type);
}
@Override
protected String doInBackground(String... f_url) {
int count;
try {
for (int i = 0; i < f_url.length; i++) {
URL url = new URL(f_url[i]);
URLConnection conection = url.openConnection();
conection.connect();
int lenghtOfFile = conection.getContentLength();
InputStream input = new BufferedInputStream(
url.openStream(), 8192);
System.out.println("Data::" + f_url[i]);
OutputStream output = new FileOutputStream(
"/mnt/sdcard/waller/" + new Date().getTime() + ".jpg");
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
publishProgress((int) ((total * 100)/lenghtOfFile));
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
protected void onProgressUpdate(Integer... progress) {
// setting progress percentage
pDialog.setProgress(progress[0]);
}
protected void onPostExecute(String file_url) {
dismissDialog(progress_bar_type);
}
}