Skip to content Skip to sidebar Skip to footer

How To Create File Directories And Folders In Android Data/data/project Filesystem

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 up ask

Solution 1:

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:

StringdirPath= getFilesDir().getAbsolutePath() + File.separator + "newfoldername";
FileprojDir=newFile(dirPath);
if (!projDir.exists())
    projDir.mkdirs();
...

Solution 2:

The proper way to get a directory that, for the primary device owner, resides under Android/data/packagename on external storage, is just to call getExternalFilesDir() on an available Context.

That is,

Filefolder= context.getExternalFilesDir("YOUR FOLDER NAME");

And also you have to add write permission in Manifest

<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Solution 3:

Solution 4:

Check out the getFilesDir method which will return the directory you're looking for. You'll probably want to make a subdirectory as well.

Solution 5:

You must try this to create folder in Android/data/data/your.app/. use this in your onCreate method.

Filefile=this.getBaseContext().getExternalFilesDir("yourFolderName");
    if (!file.exists())
        file.mkdir();

Post a Comment for "How To Create File Directories And Folders In Android Data/data/project Filesystem"