views:

82

answers:

3

Hi!

My application can be installed and run on android,
in two different places:

"/data/MyApplication"  

and

"/system/MyApplication".

I need to know where at the moment is my application installed,
if it is in "/data/" or if it is in "/system".

Can anyone help?

Thank you very much

+1  A: 

You can use adb to find out:

$ adb shell ls /data

or

$ adb shell ls /system

Or do you want this check at runtime from within your application. In that case you could use

System.getProperty("user.dir")

in your Java code.

Maurits Rijk
I really need to know this at runtime
Tsimmi
Ok, added that to my answer. Hope this helps.
Maurits Rijk
With "System.getProperty("user.dir")" I only get this: "/". ;-(
Tsimmi
Hm, wrong property maybe. Google for getProperty and Android might give you the answer. Will check this myself as well.
Maurits Rijk
+1  A: 

Obtain where your application is installed by

getPackageManager().getApplicationInfo(getPackageName(), 0).sourceDir

however this should not be important for your application. Why do you need it ?

dtmilano
I need to know where my app is installed. And yes, it will be installed as a system application but also OTA and I need to know where it is. Thanks :)
Tsimmi
+1  A: 

Please don't hard-code checks to directory paths.

You can find out of your app is part of the built-in system image with ApplicationInfo.FLAG_SYSTEM. But as the other poster says, there should be few reasons to need to do this... and note that if a newer version of your app is installed from Market on a device that has it bundled, FLAG_SYSTEM will still be set since it is still effectively a system app.

hackbod