判断是否有外置SD卡

时间:2014-05-08 22:48:26   收藏:0   阅读:332

private static String getDefaultPath(){
    boolean isHaveExternalSD = false;
    String DefaultPath = "/storage/sdcard0";
    File externalSDCard = new File("/storage/sdcard1");
    try {
        IMountService ms = getMs();
        isHaveExternalSD = ms.getVolumeState("/storage/sdcard1").equals(Environment.MEDIA_MOUNTED);
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
    if(isHaveExternalSD){
    DefaultPath = externalSDCard.toString();
    System.out.println("wangdandan1"+DefaultPath);
        }
    System.out.println("wangdandan"+DefaultPath);
    return DefaultPath;
    }

    private static IMountService getMs() {
        // TODO Auto-generated method stub
        IBinder service = ServiceManager.getService("mount");
        if (service != null) {
            return IMountService.Stub.asInterface(service);
        } else {
            System.out.println("Can‘t get mount service");
        }
        return null;
     }

判断是否有外置SD卡,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!