android 4.0 取内外置SD卡新特性
2012-11-20 10:58
260 查看
private StorageManager mStorageManager = null;
protected String mSDCardPath = null;
protected boolean mSDCardMounted = true;
protected boolean mSDCard2Mounted = false;
protected String mSDCardPath = null;
protected String mSDCard2Path = null;
mStorageManager = (StorageManager)getSystemService(Context.STORAGE_SERVICE);
String[] storagePathList = mStorageManager.getVolumePaths();
if (storagePathList != null) {
Log.d(TAG, "StorgaeList size: " + storagePathList.length);
if (storagePathList.length >= 2) {
mSDCardPath = storagePathList[0];
mSDCard2Path = storagePathList[1];
} else if (storagePathList.length == 1){
mSDCardPath = storagePathList[0];
}
}
Log.d(TAG, "SDCard path: " + mSDCardPath); //取出来的/mnt/sdcard
Log.d(TAG, "SDCard2 path: " + mSDCard2Path);//取出来的应该是/mnt/sdcard
mSDCardMounted = checkSDCardMount(mSDCardPath);
mSDCard2Mounted = checkSDCardMount(mSDCard2Path);
Log.d(TAG, "SDCard state in onCreate: " + mSDCardMounted);
Log.d(TAG, "SDCard2 state in onCreate: " + mSDCard2Mounted);
//判断sdcard是否挂载上,返回值为true证明挂载上了,否则不存在
protected boolean checkSDCardMount(String mountPoint) {
if(mountPoint == null){
return false;
}
String state = null;
state = mStorageManager.getVolumeState(mountPoint);
return Environment.MEDIA_MOUNTED.equals(state);
}
所说的4.0新特性是指针对android2.3来说的
protected String mSDCardPath = null;
protected boolean mSDCardMounted = true;
protected boolean mSDCard2Mounted = false;
protected String mSDCardPath = null;
protected String mSDCard2Path = null;
mStorageManager = (StorageManager)getSystemService(Context.STORAGE_SERVICE);
String[] storagePathList = mStorageManager.getVolumePaths();
if (storagePathList != null) {
Log.d(TAG, "StorgaeList size: " + storagePathList.length);
if (storagePathList.length >= 2) {
mSDCardPath = storagePathList[0];
mSDCard2Path = storagePathList[1];
} else if (storagePathList.length == 1){
mSDCardPath = storagePathList[0];
}
}
Log.d(TAG, "SDCard path: " + mSDCardPath); //取出来的/mnt/sdcard
Log.d(TAG, "SDCard2 path: " + mSDCard2Path);//取出来的应该是/mnt/sdcard
mSDCardMounted = checkSDCardMount(mSDCardPath);
mSDCard2Mounted = checkSDCardMount(mSDCard2Path);
Log.d(TAG, "SDCard state in onCreate: " + mSDCardMounted);
Log.d(TAG, "SDCard2 state in onCreate: " + mSDCard2Mounted);
//判断sdcard是否挂载上,返回值为true证明挂载上了,否则不存在
protected boolean checkSDCardMount(String mountPoint) {
if(mountPoint == null){
return false;
}
String state = null;
state = mStorageManager.getVolumeState(mountPoint);
return Environment.MEDIA_MOUNTED.equals(state);
}
所说的4.0新特性是指针对android2.3来说的
相关文章推荐
- Android开发:android 4.0 取内外置SD卡新特性
- android 4.0 取内外置SD卡新特性
- Android 4.0获取外置SD卡 路径
- Android学习 - 小知识(4.0以上版本读写外置sd卡与onCreate、onRestoreInstanceState、onSaveInstanceState三者关系)
- Android 4.0的12大新特性
- Android 4.0的12大新特性
- android 不同手机外置SD卡路径不同
- Android判断是否存在外置SD卡(获取手机所有存储设备的路径)
- 获得Android系统外置SD卡的路径
- Android_4.0_新特性
- android 2.3 取内外置SD卡
- Android 判断是否有外置SD卡(包含手机存储的情况下)
- Android 4.0 平台特性
- Android 应用层监听外置SD卡插拔
- Android 4.0 的 30 个惊艳的新特性
- android 6.0文件写入外置SD卡的问题!
- Android获取机身存储、内置SD卡与外置TF卡路径
- android获取内置和外置SD卡路径
- Android 4.0的12大新特性