Search code examples
androidinternal-storage

How to get absolute path of Internal Storage in Android


Internal Storage Path

Consider the above picture. It shows the folders and file in internal storage. My problem is i am not able to get the absolute path of the internal storage. I Have tried using

String path = getFilesDir().getAbsolutePath();

but it is giving me the path of my app storage. My objective is to backup a file from the private storage of my app to the top of internal storage. And i am unable to find a solution on web and neither on stack overflow. Suggest a solution to this problem!


Solution

  • Environment.getExternalStorageDirectory();

    Return the primary shared/external storage directory.

    Note: don't be confused by the word "external" here. This directory can better be thought as media/shared storage. It is a filesystem that can hold a relatively large amount of data and that is shared across all applications (does not enforce permissions). Traditionally this is an SD card, but it may also be implemented as built-in storage in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.

    File dir = Environment.getExternalStorageDirectory();
    String path = dir.getAbsolutePath();