The method getExternalStorageDirectory() can be used to get the Android external storage directory. This directory may not currently be accessible if it has been mounted by the user on their computer, has been removed from the device, or some other problem has happened. You can determine its current state with getExternalStorageState().
TextView textInfo = (TextView)findViewById(R.id.info);
String stringInfo;
String state = Environment.getExternalStorageState();
if(state.equals(Environment.MEDIA_MOUNTED)){
stringInfo = "Media Mounted:\n"
+ Environment.getExternalStorageDirectory().getPath();
}else if(state.equals(Environment.MEDIA_MOUNTED_READ_ONLY)){
stringInfo = "Media (Read Only) Mounted:\n"
+ Environment.getExternalStorageDirectory().getPath();
}else{
stringInfo = "No Media Mounted!\n";
}
textInfo.setText(stringInfo);
No comments:
Post a Comment