【问题标题】:Android: loading filesAndroid:加载文件
【发布时间】:2016-09-20 00:26:29
【问题描述】:

我需要在安卓设备上加载一个文件(我的模型)。我用

FileReader fr = null;
try {fr = new FileReader(new File(path));} catch (Exception e) {}
BufferedReader reader =...

文件的正确路径是什么(例如您从哪个文件夹开始)。还有保存模型或其他文本文件的标准位置在哪里。

【问题讨论】:

  • sdcard/yourapp/files ,通常是外部存储您的应用程序名称并将它们放在该文件夹中

标签: android file


【解决方案1】:

外部存储是它的好地方:

    public static File getMyFilePath(String filename){
        SimpleDateFormat df = new SimpleDateFormat("yyyy.MM.dd_HH.mm.ss.S");
        return new File(getDirectory(context, VIDEO_DIR),fileName);
    }
    private static File getDirectory(Context ctx, String path){
        File f=new File(context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath()+path);
        f.mkdirs();
        return f;
    }

【讨论】:

猜你喜欢
  • 2011-02-22
  • 2014-09-11
  • 2011-10-21
  • 1970-01-01
  • 1970-01-01
  • 2018-06-25
  • 2014-04-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多