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 working in activity but i don't know why it has problem in simple class.
String packageName = getPackageName();
In my class I tried to write this code:
Context context = getApplicationContext();
String packageName = context.getPackageName();
but compiler said getApplicationContext()
method is undefined for this class.
How can I take package name within this class?