Search code examples
androiddirectoryinternal-storage

absolute path to directory in the internal storage in android?


I want to keep my app required files inside a directory under internal storage. in the previous stage i used externalStorageDirectory to store my data. now i am using the below code to refer my external directory

 Environment.getExternalStorageDirectory()+"/mydirectory"; 

I need an equivalant code to refer my directory in the internal directory, can anybody help me...thanks,

Solution:

getFilesDir()+"/mydirectory";

thanks for all of your suggestion and help.


Solution

  • Use getFilesDir() for that.

    From the docs:

    Returns the absolute path to the directory on the filesystem where files created with openFileOutput(String, int) are stored.

    No permissions are required to read or write to the returned path, since this path is internal storage.

    To answer your comment, I'll quote the docs docs:

    By default, files saved to the internal storage are private to your application and other applications cannot access them (and the user only can access as root). When the user uninstalls your application, these files are removed.