当识别SDCard的时候
String filePath = null;
String state = Environment.getExternalStorageState();
if (state.equalsIgnoreCase(Environment.MEDIA_MOUNTED)) {//当SDCard挂载时
}else{//当SDCard没有挂载时
}
如果没有就下到了/data/data/app_file/目录下面去了,但安装涉及到权限问题:
try {
Process p = Runtime.getRuntime().exec("chmod 755 " + file);
int status = p.waitFor();
if (status == 0) {
// Toast.makeText(context, "权限修改成功", Toast.LENGTH_SHORT).show();
return true;
}else{
// Toast.makeText(context, "权限修改失败", Toast.LENGTH_SHORT).show();
return false;
}
} catch (IOException e) {
e.printStackTrace();
return false;
} catch (InterruptedException e) {
e.printStackTrace();
return false;
}
参考: http://www.cnblogs.com/wanqieddy/archive/2011/12/28/2304906.html
参考:http://www.cnblogs.com/wanqieddy/archive/2011/12/28/2304906.html