Reputation: 3724
I only have focused on making apps for apps that will be installed on the phone memory.
Is there any way to know dynamically the path of the application package (Environment.get...? or some other flag that can be used)? My concern is if you restore a database you must provide a destination path. That would be different depending on where the application is (sd card versus internal memory).
Upvotes: 1
Views: 285
Reputation: 28687
Are you trying to get the location of the classpath, or of the location of a class itself (classpath + package path)?
To get the location of the classpath, you can do the following:
String location = Boot.class.getProtectionDomain().getCodeSource().getLocation().getPath();
location = URLDecoder.decode(location, "UTF-8").replaceAll("\\\\", "/");
Boot would be replaced with any class.
Upvotes: 1