你可以做這樣的事情,讓你的應用程序目錄
String pathToExternalStorage = Environment.getExternalStorageDirectory().toString();
File appDirectory = new File(pathToExternalStorage + "/" + "AppName");
// have the object build the directory structure, if needed.
appDirectory.mkdirs();
現在,這是android的文檔說,創建於外部存儲自定義目錄..
如果你想保存不是特定於您的應用程序的文件,並且在卸載應用程序時不應刪除這些文件,而是將它們保存到外部存儲器上的一個公用目錄中。這些目錄位於外部存儲器的根目錄,如Music /,Pictures /,Ringtones /等。
編輯:
使用Context.getDir(字符串名稱,INT模式)方法來創建或訪問的目錄中的內部存儲。從文檔報價:
檢索,創建如果需要的話,一個新的目錄中,應用程序 可以將自己的定製數據文件。您可以使用返回的文件 對象來創建和訪問此目錄中的文件。請注意,通過File對象創建的文件 只能由您自己的 應用程序訪問;您只能設置整個目錄的模式,而不是 個別文件。
例子:
File mydir = context.getDir("mydir", Context.MODE_PRIVATE); //Creating an internal dir, set it to private so its only visible to our application;
恭維我的好答案 – 2012-01-17 02:39:42