Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a given app is installed on internal or external storage

Tags:

android

I am trying to get the location of app by passing package name to check if its installed on internal or external storage. Please help.

like image 284
user606669 Avatar asked Dec 06 '25 06:12

user606669


1 Answers

U can check this code and see whether we have installed on internal or external storage

(Note: u can use it in oncreate or any where)

ApplicationInfo io = getApplicationContext().getApplicationInfo();

if(io.sourceDir.startsWith("/data/")) {
Toast.makeText(this,"your app is in internal storage",Toast.LENGTH_LONG).show();

//application is installed in internal memory
} else if(io.sourceDir.startsWith("/mnt/") || io.sourceDir.startsWith("/sdcard/")) {
Toast.makeText(this,"your app is in external storage",Toast.LENGTH_LONG).show();
//application is installed in sdcard(external memory)
}
like image 140
Sureshbabu T Avatar answered Dec 08 '25 19:12

Sureshbabu T



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!