마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

(No such file or directory) 해결좀 해주세요 ㅠㅠ

0 추천
<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();
            } 이 기능도 수행하지 못하고 있어요 ㅠㅠ

다른 앱에서 이 코드 쓸때는 됬엇는데 지금 만들고 있는 앱에서는 안되네요 ㅠㅠ 해결방법이 있을까요??
퍼너 (130 포인트) 님이 2016년 5월 19일 질문

1개의 답변

+1 추천
6.0 이상이면 runtime permission 확인을 해야 합니다.
익명사용자 님이 2016년 5월 20일 답변
감사합니다 ㅠㅠㅠ runtime permission이 몰라서 이곳저곳 또 검색했지만 해결했어요!!!
...