Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out if an App has been moved to SD card on Android

I used the installLocation that allows figuring out if an app can be moved or not. But I cannot figure out what happens when we want to find out if an App has been moved to a SD card.

The ApplicationInfo attribute FLAG_EXTERNAL_STORAGE only tells you if the app is installed to the SD not if it has been moved to. I am generating a list of apps that could be moved to SD card. So first list I generate is using the installLocation of manifest. From this list I got to filter out apps which already have been moved to SD Card.

like image 303
Kawlym Baygh Avatar asked Feb 14 '12 22:02

Kawlym Baygh


1 Answers

To Check application is installed in SD Card or not, just do this:

ApplicationInfo io = context.getApplicationInfo();

if(io.sourceDir.startsWith("/data/")) {

//application is installed in internal memory

} else if(io.sourceDir.startsWith("/mnt/") || io.sourceDir.startsWith("/sdcard/")) {

//application is installed in sdcard(external memory)

}
like image 140
E Player Plus Avatar answered Nov 15 '22 12:11

E Player Plus