storageRef = storage.getReferenceFromUrl("gs://chatapp-asdzc7f.appspot.com");
storageReference = storageRef.child("image").child(imageFileName);
try
{
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath()+"/TackAlbum");
if(!file.exists())
{
Log.e("path = ", "not exists 생성");
file.mkdirs();
}
File localFile = new File(file, imageFileName);
storageReference.getFile(localFile)
.addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
Log.e("download = ", "Start");
try {
MediaStore.Images.Media.insertImage(context.getContentResolver(),
localFile.getPath(), localFile.getName(), null);
context.sendBroadcast(new Intent(
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(localFile)));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Log.e("download content uri = ", String.valueOf(Uri.fromFile(localFile)));
Log.e("download = ", "Successs");
Toast.makeText(context, "Download Success!!", Toast.LENGTH_SHORT).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle failed download
// ...
Log.e("downloadImageFile", "download failed");
Log.e("downloadimageFile", String.valueOf(exception));
}
});
}
catch(Exception e)
{
e.printStackTrace();
}
}
이렇게 firebase에서 사진을 내려받는데요 결과적으로 핸드폰 내에 Picture 폴더에 저장되고 Log 찍어보면
file:///storage/emulated/0/Pictures/TackAlbum/20180727_220403qweasdqwesadfdsa.jpg
이런식으로 Picture 밑에 TackAlbum 안에 이미지가 들어가있고 실제로도 그렇고요 그런데 문제는
갤러리를 들어가보면 사진이 저장된 폴더가 Picture에요 위에 경로 처럼 TackAlbum 이 아니라 Picture 로 나와요 왜 이러는지 모르겠어요 분명 Picture 안에 TackAlbum만들고 그 안에 이미지 넣고 실제로도 그런데 갤러리에서만 Picture에 있는게 이해가 안되네요;; 해답 부탁드립니다 !!