PackageInfo的操作

一、判断当前SD卡是否存在:

 

public static boolean isSdcardAvaliable(){
		boolean isAvaliable = false ;
		try {
			if(android.os.Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
				isAvaliable =  true;
			}
			else {
				isAvaliable =  false;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return isAvaliable;
	}

 

二、判断应用是否安装在SD卡里面,还是手机里面:

if((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE)!=0){
               //应用程序安装在sd上面
 } 

 

你可能感兴趣的:(package)