Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Android) Find path /Android in internal storage

Is there a method in Android that returns the data path on internal storage?

I have 2 Android smartphone (Samsung s2 and s7 edge) where i installed an application. I want to take a sqliteDB situated in this path:

/Android/data/application.most/files/most_db

The problem is that in Samsung s2 i must use this path to take the DB:

private static final String db_path = "/storage/sdcard0/Android/data/org.application/files/application_db";

Instaed, in s7 i must use this:

private static final String db_path = "/storage/emulated/0/Android/data/application.most/files/application_db";

I want to take this path independently by device.

Can you help me?

Thanks in advance.

like image 337
Federico Avatar asked May 28 '16 09:05

Federico


People also ask

What is the path for Android internal storage?

Internal Storage(UT) location: /storage/sdcard0 . Note that /sdcard & /storage/emulated/0 also point to Internal Storage(UT).

Where is internal storage located?

Your app's portion of internal storage will be on the /data/ partition. Exactly where depends upon the account that is running your app (Android 4.2+ supports multiple accounts per device). The primary device account will have your app's portion of internal storage be at /data/data/your.


Video Answer


2 Answers

I think that what you're looking for is something like that

String path = getFilesDir().getAbsolutePath();
like image 112
antonis_st Avatar answered Sep 27 '22 17:09

antonis_st


Once change your Logic in different versions.. till android 4.xx it take internal memory as /storage/sdcard0/ where as from 4.4 kitKat it will take path as /storage/emulated/0/

Design multiple apk depending on android API versions...

your problem is solved.. you can install it in s2 with that path and S7 with this path...

like image 26
Don't Be negative Avatar answered Sep 27 '22 17:09

Don't Be negative