在公共添加文件夹中的内部存储? [英] Adding folder in Internal Storage in public?

查看:189
本文介绍了在公共添加文件夹中的内部存储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的 Excel文件将其存储在内部存储,但我不能只do.It应用存储directory.Not可见在public.How创建文件夹,里面存放创建该文件夹中的文件?任何人都可以人知道帮我解决这个问题。

文件创建编码

 公共字符串生成(FILE_NAME字符串,字符串路径){    尝试{        F =新的文件(activity.getFilesDir(),路径);
        如果(!f.exists()){
           f.mkdirs();
        }
        文件=新的文件(f.getAbsolutePath(),FILE_NAME);
        如果(file.createNewFile()){
            file.createNewFile();
        }        wb_setting =新WorkbookSettings();
        wb_setting.setLocale(新区域设置(恩,EN));        工作簿= Workbook.createWorkbook(文件,wb_setting);
        workbook.createSheet(报告,0);
        excelSheet = workbook.getSheet(0);
        createLabel(excelSheet);
        createContent中(excelSheet);        workbook.write();
        workbook.close();        file_path_alert_builder =新AlertDialog.Builder(活动);
        file_path_alert_builder.setTitle(文件路径);
        file_path_alert_builder.setMessage(+文件).setCancelable(真).setPositiveButton(OK,新DialogInterface.OnClickListener(){
            @覆盖
            公共无效的onClick(DialogInterface dialogInterface,int i)以{                dialogInterface.dismiss();            }
        });        file_path_dialog = file_path_alert_builder.create();
        file_path_dialog.show();
    }赶上(JXLException jxl_e){
        jxl_e.printStackTrace();
    }赶上(MalformedURLException的E){
        e.printStackTrace();
    }赶上(IOException异常五){
        e.printStackTrace();
    }    返回null;
}


解决方案

你必须选择正确的道路在哪里存储的文件。有多种选项

内部存储


  • 内部应用程序(用于从外部最终用户不能访问)

  • 缓存目录(也可以,如果系统运行的空间被清除)

外部存储(验证它是否可用,使用它)虽然有2种类型是公共


  • 公共

  • 私有(由用户和其他应用技术上访问,因为他们是在外部存储,它们是现实不提供价值,你的应用程序之外的用户文件。)

每个路径位置可以由Android提供不同的API来访问。看到 http://developer.android.com/training/basics/data-存储/ files.html

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

  • internal to app (not accessible for end users from outside)
  • cache directory (it can be cleared if system is running out of space)

External Storage (verify if it is available and use it) Although it is public there are 2 types

  • public
  • private (technically accessible by the user and other apps because they are on the external storage, they are files that realistically don't provide value to the user outside your app. )

each path location can be accessed with different API provided by android. see http://developer.android.com/training/basics/data-storage/files.html

这篇关于在公共添加文件夹中的内部存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆