2016-09-20 86 views
0

我需要加载Android设备上的文件(我的模型)。我使用Android:加载文件

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

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

+0

SD卡/ yourapp /文件,通常外部存储的程序名称,并把他们怎么过该文件夹 – surya

回答

0

外部存储是它的一个好去处:

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; 
    } 
+0

我在Android Studio中的编码,怎能内我将文件保存到外部存储? – Shadow

+0

@Shadow看看这个https://developer.android.com/training/basics/data-storage/files.html – leotesta

+0

@Shadow也许你会搜索http://stackoverflow.com/questions/18302603/where-to- place-assets-folder-in-android-studio –