Android Forum » Android Developer Forum » Android Developer Forum (general) » What's the root of my app?
created on Dec 15, 2012 4:07:25 PM
i'm trying to develop a simple android app.
I want to know if an image exist in one of my app folder, but i dont' know what's the root of my app; i tried
File nomeFile = new File("res/drawable-hdpi/imagename.jpg")
File nomeFile = new File("myappanem/res/drawable-hdpi/imagename.jpg")
but it doens't work
Can somebody help me?
created on Dec 27, 2012 7:12:59 PM
— modified on Dec 27, 2012 7:13:54 PM
PackageManager pm = getPackageManager();
String dataDir = getPackageName();
PackageInfo pi = pm.getPackageInfo(dataDir, 0);
dataDir = pi.applicationInfo.dataDir;
created on Dec 27, 2012 7:17:59 PM
anyway, resources are normally accessed by id, like this: R.drawable.imagename