am創建Excel文件將其存儲在內部存儲器中,但無法完成。它僅在應用程序存儲目錄內創建。不能在public中顯示。如何創建文件夾並將文件存儲在該文件夾中?任何人都可以幫助我解決這個問題。公開在內部存儲中添加文件夾?
文件創建編碼
public String generate(String file_name,String path) {
try {
f = new File(activity.getFilesDir(), path);
if (!f.exists()) {
f.mkdirs();
}
file = new File(f.getAbsolutePath(), file_name);
if (file.createNewFile()) {
file.createNewFile();
}
wb_setting = new WorkbookSettings();
wb_setting.setLocale(new Locale("en", "EN"));
workbook = Workbook.createWorkbook(file, wb_setting);
workbook.createSheet("Report", 0);
excelSheet = workbook.getSheet(0);
createLabel(excelSheet);
createContent(excelSheet);
workbook.write();
workbook.close();
file_path_alert_builder = new AlertDialog.Builder(activity);
file_path_alert_builder.setTitle("File path");
file_path_alert_builder.setMessage(""+file).setCancelable(true).setPositiveButton("OK",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
file_path_dialog = file_path_alert_builder.create();
file_path_dialog.show();
}catch (JXLException jxl_e) {
jxl_e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
好吧,但一些流行的應用程序,如什麼,Viber,camscanner應用程序有文件夾來顯示文件在內部存儲。 – Yugesh 2014-11-04 09:55:37
他們使用外部存儲。可以使用getExternalFilesDir()。 – Aun 2014-11-04 10:04:31