How to create file directories and folders in Android data/data/project filesystem

前端 未结 4 1348
粉色の甜心
粉色の甜心 2021-02-02 16:12

I am working on a video editor program and am fairly new to android and java. What I would like to happen is when the user presses \"create new project\" button, a dialog pops u

4条回答
  •  情书的邮戳
    2021-02-02 17:05

    As sgarman proposed you can use the SD card (and I think it's better) but if you want to use your application dir you can get it by calling getFilesDir() from your activity, it will return a File object of /data/data/your.app/files then you can get the path and append the new directory:

    String dirPath = getFilesDir().getAbsolutePath() + File.separator + "newfoldername";
    File projDir = new File(dirPath);
    if (!projDir.exists())
        projDir.mkdirs();
    ...
    

提交回复
热议问题