![](/img/trans.png)
[英]Why there are two folders sdcard and sdcard2 under /mnt on my android device
[英]How to create new files in my external slot SDCARD ( its not in internal storage) - “/mnt/sdcard2/”
我的問題是我需要使用外部插槽sdcard中的文件,請不要建議我使用Environment.getExternalStorageDirectory()
-它用於內部存儲,我想在外部存儲中創建文件
關於什么
File myFile = new File("/mnt/sdcard2/myFile");
編輯:忘記提及您必須創建文件:
boolean fileCreated = myFile.createNewFile();
//at this point fileCreated must be true and the file must exists on your sdcard2
編輯:
從File.createNewFile()javadoc:
/**
* ...
* @return true if the file has been created, false if it
* already exists.
* @throws IOException if it's not possible to create the file.
*/
因此,要么創建該文件,要么已經存在該文件,要么您得到IOException ...或者您的代碼未調用createNewFile()...
我認為這不可能。 當我在自己的應用程序上工作時,如果有內部可寫內存,則會遇到相同的問題。 搜索了幾天,試圖找出如何獲取實際的外部SD卡,但沒有運氣。
我認為這是因為android使用存儲的方式,內部sd卡稱為SDCARD,外部的sd卡鏈接到SDCARD0(或者類似的東西在我頭上不記得了)。 運行getExternalStorage時,它只會查找SDCARD並轉到內部存儲。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.