Is there a way to get it through the context file or the package-manager? Have searched for it but didn’t find anything.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just call getPackageName() on your context. You can call this in any Activity, Service, or basically anything that inherits from Context.
Other than that, if you want to access it somewhere without a context, just create a separate class to hold preknown values like this:
and then access it anywhere in your app using
MyConstants.PACKAGE_NAMEwherever you need it.