<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 퍼미션을 주었는데도
디렉토리를 만들지도 못하고 임의로 만들어도
(Permission denied)
라는 오류가 뜨네요 ㅠㅠ
try {
String dirName = "hello";
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
String imgName = format.format(new Date());
File sdCardPath = Environment.getExternalStorageDirectory();
File dirs = new File(sdCardPath,dirName);
if(!dirs.exists()) {
dirs.mkdirs();
}
saveLayout.buildDrawingCache();
Bitmap captureView = saveLayout.getDrawingCache();
File img = new File(sdCardPath.getAbsolutePath() + "/" + dirName + "/" + imgName
+ ".jpeg");
FileOutputStream fos = new FileOutputStream(img);
captureView.compress(Bitmap.CompressFormat.JPEG, 100, fos);
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
Uri.parse("file:/"+ Environment.getExternalStorageDirectory())));
Toast.makeText(this, "저장완료", Toast.LENGTH_LONG).show();
//addDB(img);
} catch (Exception e) {
e.printStackTrace();
}
위에 코드중에서
FileOutputStream fos = new FileOutputStream(img); 이부분에서 에러가 한번 더 나는데
그전에
if(!dirs.exists()) {
dirs.mkdirs();
} 이 기능도 수행하지 못하고 있어요 ㅠㅠ
다른 앱에서 이 코드 쓸때는 됬엇는데 지금 만들고 있는 앱에서는 안되네요 ㅠㅠ 해결방법이 있을까요??