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

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


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();...


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,

File folder = context.getExternalFilesDir("YOUR FOLDER NAME");

And also you have to add write permission in Manifest

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


You can do almost all of that using the File and use something like this Save an edited image to the SD card