Search code examples
androidstoragegetdirectories

Differences between different getdir() function in android


What are the difference between these kinds of getdir() functions? I search through Internet, but seems all of them have same function. Then what are the use of them?

getExternalFilesDir()
getExternalFilesDirs()
getExternalCacheDir()
getExternalCacheDirs()
getExternalStorageDirectory()
getExternalStoragePublicDirectory()
getFilesDir()

Solution

  • getExternalFilesDir(String type)

    Returns the absolute path to the directory on the primary shared/external storage device where the application can place persistent files it owns.

    getExternalFilesDirs()

    Returns absolute paths to application-specific directories on all shared/external storage devices where the application can place persistent files it owns.

    getExternalCacheDir()

    Returns absolute path to application-specific directory on the primary shared/external storage device where the application can place cache files it owns.

    getExternalCacheDirs()

    Returns absolute paths to application-specific directories on all shared/external storage devices where the application can place cache files it owns.

    getExternalStorageDirectory()

    Return the primary shared/external storage directory.

    getExternalStoragePublicDirectory(String type)

    Get a top-level shared/external storage directory for placing files of a particular type.

    getFilesDir()

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

    these documentations will help you