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

API 레벨에 따른 sdcard경로

0 추천

구글 문서를 보니

Accessing files on external storage

If you're using API Level 8 or greater, use getExternalFilesDir() to open a File that represents the external storage directory where you should save your files. This method takes a type parameter that specifies the type of subdirectory you want, such as DIRECTORY_MUSIC and DIRECTORY_RINGTONES (pass null to receive the root of your application's file directory). This method will create the appropriate directory if necessary. By specifying the type of directory, you ensure that the Android's media scanner will properly categorize your files in the system (for example, ringtones are identified as ringtones and not music). If the user uninstalls your application, this directory and all its contents will be deleted.

If you're using API Level 7 or lower, use getExternalStorageDirectory(), to open a File representing the root of the external storage. You should then write your data in the following directory:

/Android/data/<package_name>/files/

The <package_name> is your Java-style package name, such as "com.example.android.app". If the user's device is running API Level 8 or greater and they uninstall your application, this directory and all its contents will be deleted.

 

이렇게 나와있는데 제가 API 레벨을 8부터 17까지 지정해놓고 개발을 합니다.

근데 문서상에 레벨7 이하는 getExternalStorageDirectory() 이걸 쓰라는데 저는 그냥 이거 쓰고 있거든요. 근데 테스트해보면 8이상 레벨에서 다 잘됩니다. 

문서에 따르면 8이상은 getExternalFilesDir() 이걸 쓰라는데 별 차이가 없는 건가요?

브루스웨인 (8,580 포인트) 님이 2013년 7월 22일 질문

1개의 답변

+1 추천
 
채택된 답변
getExternalStorageDirectory는 외장 메모리, 즉 sdcard 이거나 내장 메모리지만 시스템 영역을 제외한 부분의 메모리 부분에 대한 정보를 File로 반환합니다.

 

이곳에 파일을 읽고 쓸수 있는데요. 앱을 삭제해도 이곳에 작업했던 파일은 남아있습니다.

 

getExternalFilesDir은 외장 메모리에 자기 앱에 할당된 부분에 대한 정보를 File로 반환합니다.

대부분 "sdcard/Android/data/앱의 패키지명/" 구조를 가지고 있습니다.

이곳에 파일을 생성하거나 하면 앱이 삭제될때 OS에서 이곳의 폴더도 같이 삭제해 줍니다.
원조안드로이드 (58,190 포인트) 님이 2013년 7월 22일 답변
브루스웨인님이 2013년 7월 26일 채택됨
getExternalStorageDirectory 는 시스템영역을 제외한 내외장 메모리 부분을 보여주는건가요?

그럼 getExternalFilesDir 은 내장메모리를 제외한 외장메모리 영역을 가리키는 건가요?
...