String root = Environment.getExternalStorageDirectory().toString();
File myDir = new File(root + "/Download");
myDir.mkdirs();

String fname = "image.jpg";

File file = new File (myDir, fname);
if (file.exists ()) file.delete ();
try {
FileOutputStream out = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();

Toast.makeText(mContext, fname + "다운로드 되었습니다", Toast.LENGTH_SHORT).show();

} catch (Exception e) {
e.printStackTrace();
}


'android' 카테고리의 다른 글

pendingIntent Flag 옵션  (1) 2018.02.02
TextView 선택 복사  (0) 2018.01.19
웹뷰 바로 전의 URL 가져오기  (0) 2017.12.12
코드로 원 그리기  (0) 2017.12.11
마테리얼 디자인 정리가 잘되어있어 올립니다.  (0) 2017.12.02

+ Recent posts