2012-01-03 69 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