마스터Q&A
접속유지
가입하기
안드로이드 Q&A
최근 질문
미답변 질문
태그
사용자
질문하기
마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다.
안드로이드펍
에서 운영하고 있습니다. [
사용법
,
운영진
]
인기있는 태그
초보어플개발
(3427)
안드로이드스튜디오
(2664)
안드로이드-초보어플개발
(1333)
안드로이드-스튜디오
(1086)
도와주세요-
(995)
이미지
(970)
listview
(866)
리스트뷰
(844)
오류
(805)
레이아웃
(693)
fragment
(675)
webview
(670)
안드로이드 getExternalStorageDirectory 질문입니다.
0
추천
usb 경로를 가져오는 개발도중에 드는 의문이 생겼는데
getExternalStorageDirectory 라는단어가 외부저장소를 가져오는것인데 내부저장소를 가져오는이유가 무엇일까요??
getExternalStorageDirectory.getabsolutepath가 내부저장소를 가져온다면 진짜로 안드로이드가 usb를 인식했을때 외부저장소인 usb경로를 가져오려면 어떻게해야 가져올수있을까요??
안드로이드
android
dsafdsf
(
300
포인트)
님이
2016년 8월 17일
질문
Please
log in
or
register
to add a comment.
답변 달기
·
글에 소스 코드 보기 좋게 넣는 법
·
질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
답변이 채택되거나 답변에 댓글이 달리면 이메일로 알려드립니다:
답변이 채택되거나 댓글이 달리면 이메일로 알려드립니다
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면
로그인
하거나 혹은
가입
하세요.
1개의 답변
0
추천
채택된 답변
초기 안드로이드 제품들을 보면 외장메모리가 없었습니다.
따라서, 외장메모리가 없으면, 저장용량이 많이 필요한 카메라앱 같은 경우, 동작을 하지 않았습니다.
시간이 지나고 소토리지가 대용량화 되면서 외장메모리가 스마트폰에 내장되었다고 생각하시면 됩니다.
물리적으로 내장되었다고 생각하시면 될 것 같습니다.
removable storage의 경우
http://devbible.tistory.com/277
참조해서 구현하시면 되겠습니다.
안_드루이드
(
14,510
포인트)
님이
2016년 8월 17일
답변
dsafdsf
님이
2016년 8월 17일
채택됨
답변 감사합니다. 덕분에 첫번째 의문점이 해결이되었습니다.
그런데 해당url을 참고하여 usb 경로값을받아오면 /mnt/media_rw/UsbDriveA
를 반환값으로 받는데 실제경로는 /storage/UsbDriveA입니다.
다른방법은 없을까요??
String strSDCardPath = System.getenv("SECONDARY_STORAGE");
if ((strSDCardPath == null) || (strSDCardPath.length() == 0)) {
strSDCardPath = System.getenv("EXTERNAL_SDCARD_STORAGE");
}
//If may get a full path that is not the right one, even if we don't have the SD Card there.
//We just need the "/mnt/extSdCard/" i.e and check if it's writable
if(strSDCardPath != null) {
if (strSDCardPath.contains(":")) {
strSDCardPath = strSDCardPath.substring(0, strSDCardPath.indexOf(":"));
}
File externalFilePath = new File(strSDCardPath);
if (externalFilePath.exists() && externalFilePath.canWrite()){
//do what you need here
}
}
이렇게 한번 해보세요..
답변감사합니다 답변대로 실행한결과
strSDCardPath = System.getenv("SECONDARY_STORAGE");
if ((strSDCardPath == null) || (strSDCardPath.length() == 0)) {
strSDCardPath = System.getenv("EXTERNAL_SDCARD_STORAGE");
}
//If may get a full path that is not the right one, even if we don't have the SD Card there.
//We just need the "/mnt/extSdCard/" i.e and check if it's writable
if(strSDCardPath != null) {
if (strSDCardPath.contains(":")) {
strSDCardPath = strSDCardPath.substring(0, strSDCardPath.indexOf(":"));
}
File externalFilePath = new File(strSDCardPath);
if (externalFilePath.exists() && externalFilePath.canWrite()){
//do what you need here
}
}
Log.i("test","strSDCardPath : " + strSDCardPath);
로그값결과 strSDCardPath : /storage/extSdCard 해당경로에는 아무런파일이없습니다.
위와같이 /storage/UsbDriveA 경로값을 받질못합니다.
안되면 아까전 방법에서 실제 파일을 생성해 보세요. 알다시피 리눅스에서는 디렉토리 자체도 링크가 되기 때문에 디렉토리 명이 달라도 물리적으로는 같은 디레토리 일수도 있습니다.
Please
log in
or
register
to add a comment.
...