2012-01-03 68 views
1

在我的应用程序,我需要从服务器下载一个文件到SD卡。但在这里下载之前我需要选择文件夹(任何文件夹)在SD卡中文件应该下载所以如何选择SD卡中的文件夹?如何选择一个文件夹下载文件在SD卡

+1

@WarrenFaith同意你,为什么我应该浪费我的时间。 – 2012-01-03 10:32:27

+0

您可以随时尝试[在StackOverflow上搜索](http://stackoverflow.com/search?q=android+select+file)或[在Google上搜索](https://www.google.com/# sclient = PSY-AB&HL = EN&站点=&源= HP&q =选择+文件+机器人&PBX = 1&OQ =选择+文件+机器人&水溶液= F&AQI = G1G-B3&AQL =&gs_sm = E&gs_upl = 574l2741l0l3721l19l13l0l1l1l0l446l2438l0.9.3.0.1l14l0&BAV = on.2,or.r_gc .r_pw.r_cp。,cf.osb&FP = a1bc1589ec616832&BIW = 1680&波黑= 925)。 – Jakar 2012-01-03 10:37:39

回答

-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"); 
} 

对不起,昨天我想把我的代码复制到这里,但是复制这些代码,这是正确的。

+0

-1为无证,无法解释的代码答案...和缺少格式 – WarrenFaith 2012-01-03 11:39:22

+0

对不起,我不擅长英语。但我真的已经保存在SD卡中的图像。 @WarrenFaith – peanut 2012-01-04 03:12:09

+0

@WarrenFaith我发表错误的话!我会改变它。 – peanut 2012-01-04 09:18:28