<안드로이드>개발/안드로이드/App

[팁] SDCARD의 상태 확인

소혼 2010. 6. 26. 12:16
반응형
마무리 작업을 하고 있다.
타겟에 올려보니 실제와 다른 부분이 몇가지 있다.

특히 SDCARD부분이 다소 달랐다.
만약, SDCARD가 컴퓨터에 연결이 되어 있다면 디바이스에 인스톨된 어플리케이션은 SDCARD에 접근을 하지 못하는 것 같다.

곰곰히 생각해보니, 만약 어플 사용자가 선을 연결해놓고 실행하려 하는 경우 동일한 문제가 발생할 수 있다는 생각이 들었다.

따라서 SDCARD를 사용하려면 반드시 사용하기 전에 SDCARD의 상태가 정상적인지 확인하는 것이 필요하다.

SDCARD의 상태를 확인하는 것은 getExternalStorageState() 를 사용하면 된다.
android.os.Environment.getExternalStorageState()
아래는 안드로이드 Developer 자료
Constants
String MEDIA_BAD_REMOVAL getExternalStorageState() returns MEDIA_BAD_REMOVAL if the media was removed before it was unmounted.
String MEDIA_CHECKING getExternalStorageState() returns MEDIA_CHECKING if the media is present and being disk-checked
String MEDIA_MOUNTED getExternalStorageState() returns MEDIA_MOUNTED if the media is present and mounted at its mount point with read/write access.
String MEDIA_MOUNTED_READ_ONLY getExternalStorageState() returns MEDIA_MOUNTED_READ_ONLY if the media is present and mounted at its mount point with read only access.
String MEDIA_NOFS getExternalStorageState() returns MEDIA_NOFS if the media is present but is blank or is using an unsupported filesystem
String MEDIA_REMOVED getExternalStorageState() returns MEDIA_REMOVED if the media is not present.
String MEDIA_SHARED getExternalStorageState() returns MEDIA_SHARED if the media is present not mounted, and shared via USB mass storage.
String MEDIA_UNMOUNTABLE getExternalStorageState() returns MEDIA_UNMOUNTABLE if the media is present but cannot be mounted.
String MEDIA_UNMOUNTED getExternalStorageState() returns MEDIA_UNMOUNTED if the media is present but not mounted.

최소한 MEDIA_SHARED 상태인지 확인하는 것이 필요하다고 여겨진다.

허접한 글이지만, 도움이 되셨다면 아래 손가락 꾹 눌러주세요.
반응형