在我的应用程序中,我需要从服务器下载文件到sdcard.But这里在下载之前我需要在sdcard中选择文件应该下载的文件夹(任何文件夹)。那么如何选择sdcard中的文件夹?
答案 0 :(得分:-3)
这就是我如何在SD卡中保存我的照片。
OutputStream stream = null;
File tmpFile = creatTempFile();
try {
stream = new FileOutputStream(tmpFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
yourImage.compress(Bitmap.CompressFormat.JPEG, 80, stream);
private File creatTempFile(){
final File path = new File( Environment.getExternalStorageDirectory(), "folder_name" );
if(!path.exists()){
path.mkdirs();
}
return new File(path, "file_name");
}
抱歉,昨天我想将我的代码复制到这里,但复制忧虑代码,这是对的。