标签:not turn tput form director 资源 jpg param save
/**
* 判断SDCard是否存在 [当没有外挂SD卡时,内置ROM也被识别为存在sd卡]
*
* @return
*/
public static boolean isSdCardExist() {
return Environment.getExternalStorageState().equals(
Environment.MEDIA_MOUNTED);
}
/**
* 获取SD卡根目录路径
*
* @return
*/
public static String getSdCardPath() {
boolean exist = isSdCardExist();
String sdpath = "";
if (exist) {
sdpath = Environment.getExternalStorageDirectory()
.getAbsolutePath();
} else {
sdpath = "不适用";
}
return sdpath;
}
//将资源图片存到本地
public void writeFile(){
try {
File file = new File(getCacheDir().getAbsolutePath()+
"/renlian.jpg");
Bitmap bitmap=BitmapFactory.decodeResource(getResources(),R.mipmap.a);
savePic(bitmap,file);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 保存图片到本地
*
* @param b
* @param filePath
*/
private void savePic(Bitmap b, File filePath) {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(filePath);
if (null != fos) {
b.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();
main();
}
} catch (FileNotFoundException e) {
// e.printStackTrace();
} catch (IOException e) {
// e.printStackTrace();
}
}
标签:not turn tput form director 资源 jpg param save
原文地址:http://www.cnblogs.com/cxb-comeon/p/6678870.html