, 수 있도록 당신이 권한을 추가해야합니다 : 외부 저장 읽기 가능하며 루트
public boolean isExternalStorageWritable() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
return true;
}
return false;
}
사용을 작성하는 경우
<manifest ...>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
...
확인을 안드로이드의 루트를 사용하는 대신 공개 디렉토리의. 당신은 외부 저장 장치에 저장된 공용 파일을 저장하려는 경우에는 getExternalFilesDir()를
public File getAlbumStorageDir(Context context, String albumName) {
// Get the directory for the app's private pictures directory.
File file = new File(context.getExternalFilesDir(
Environment.DIRECTORY_DCIM), albumName);
if (!file.mkdirs()) {
Log.e(LOG_TAG, "Directory not created");
}
return file;
}
사용하는 앱에 비공개 파일을 저장하려면
는 getExternalStoragePublicDirectory()
public File getAlbumStorageDir(String albumName) {
// Get the directory for the user's public pictures directory.
File file = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DCIM), albumName);
if (!file.mkdirs()) {
Log.e(LOG_TAG, "Directory not created");
}
return file;
}
를 사용
내가 언급하는 것을 잊었다 :
decodeFile
경로를 예상
"자르기 의도를 통해 SDcard에 비트 맵 파일을 저장했습니다."- [Android에 'CROP'' Intent'가 없습니다.] (https://commonsware.com/blog/2013/01/23/no -android-does-not-have-crop-intent.html). "스트림을 디코드 할 수 없습니다 : java.io.FileNotFoundException : file : /sdcard/oc.jpg"- 경로를 하드 코딩하지 말고 ('Environment.getExternalStorageDirectory()'와 같은 메소드 사용) 적절한 권한이 있는지 확인하십시오 (런타임 권한 포함). – CommonsWare
내가 시도한 문자열 imageInSD = Environment.getExternalStorageDirectory(). getAbsolutePath() + "oc.jpg"; image4 = BitmapFactory.decodeFile (imageInSD); 하지만 여전히 비트 맵을 읽지 못했고 런타임 권한이 포함되었습니다. – MKH
'.... getAbsolutePath() + "oc.jpg"'.getAbsolutePath() + "/ oc.jpg"' – greenapps