am create the Excel file to store it in Internal storage,but am not able to do.It Create only inside the app storage directory.Not to visible in public.How to create folder and store the file in that folder?Can anyone one know help me to solve this issue.
File Creation coding
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;
}
you have to choose the right path where to store the files. There are multiple options
Internal storage
External Storage (verify if it is available and use it) Although it is public there are 2 types
each path location can be accessed with different API provided by android. see http://developer.android.com/training/basics/data-storage/files.html