Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android getting external storage Absolute Path

I want to download some files and save them into the internal storage of the phone/tab. Tried on Samsung Galaxy Note 2 and Galaxt Tab 10.1. When I use /storage/sdcard0/ on them the code runs successfully but when I use Galaxy Nexus 3 the code fails.

I want to get absolute path of the phoe or tab's internal storage' Absolute Path.

Does it possible, if so how?

like image 683
Erdinç Özdemir Avatar asked Jul 09 '13 11:07

Erdinç Özdemir


People also ask

What is external storage path in Android?

Android External Storage Example Code getExternalFilesDir(): It returns the path to files folder inside Android/data/data/application_package/ on the SD card. It is used to store any required files for your app (like images downloaded from web or cache files).

What are the two methods are used to find out absolute path of file in internal storage?

Show activity on this post. String path = getFilesDir(). getAbsolutePath();

How do I find my internal storage path?

With Google's Android 8.0 Oreo release, meanwhile, the file manager lives in Android's Downloads app. All you have to do is open that app and select the "Show internal storage" option in its menu to browse through your phone's full internal storage.


1 Answers

When I use /storage/sdcard0/ on them the code runs successfully but when I use Galaxy Nexus 3 the code fails.

/storage/sdcard0/ is not internal storage. It is external storage.

(BTW, since there is no device named "Galaxy Nexus 3", I am assuming that you simply meant "Galaxy Nexus")

To find locations on internal storage for your app, use getFilesDir(), called on any Context (such as your Activity, to get a File object.

To get a location on external storage unique for your app, use getExternalFilesDir(), called on any Context (such as your Activity, to get a File object.

To get a standard location on external storage for common types of files (e.g., movies), use getExternalStoragePublicDirectory() on Environment.

To get the root of external storage, use getExternalStorageDirectory() on Environment. This, however, is considered sloppy programming nowadays, as it encourages developers to just put files in random locations.

like image 78
CommonsWare Avatar answered Oct 10 '22 08:10

CommonsWare