[Solved] 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!

Enquirer: Dilazak


Solution #1:


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();
Respondent: Dilazak

Solution #2:

It is only possible with root access. You should write you backup to external storage to make it world-readable. Android docs says that if you want to share file with other apps or store this file even after app will be deleted you should save it to external storage. Android docs

Respondent: Nabin Bhandari

Solution #3:

Try this,

String path = Environment.getExternalStorageDirectory().getAbsolutePath();
Respondent: Romadro

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published. Required fields are marked *

New ride at Perth's Adventure World a ‘swing on steroids’ - Australasian Leisure Management npp pharma the truth about anabolic steroid drugs and professional sports