In my application I need to know the name of package name. I have no problem when I want to grab it in activities but i can\'t take it in other classes. Following code is workin
Using instance of the class you can get package name by using getClass().getPackage().getName() to the instance
getClass().getPackage().getName()
Sample Code
ClassA instanceOfClass = new ClassA(); String packageName = instanceOfClass.getClass().getPackage().getName(); System.out.println("Package Name = " + packageName);