I have a very simple question:
Given a specific resource (id,string,drawable,...) from R.java file, is it possible to know which qualifiers it had on its folder that matched it? If so, how ?
For example, if my device has a screen with hdpi density , and i have the same filename "x.png" on "res/drawable-hdpi" and "res/drawable-mdpi" , and i'm about to decode this file, what i would want to get is that it got the file from res/drawable-hdpi , and by doing it know that it has the hdpi density .
Of course, in this example , if the file exists on other folders , but not on the hdpi folder, I would want it to tell me which one will be used when I decode the file.
Same goes for the rest of the qualifiers (locale, screenSize,...) .
You can use this qualifier to ensure that your app has at least <N> dps of width available for its UI. For example, if your layout requires that its smallest dimension of screen area be at least 600 dp at all times, then you can use this qualifier to create the layout resources, res/layout-sw600dp/ .
What is a qualifier? It is a constraint, indicating that the directory's worth of resources is targeting a particular certain devices and configurations. So, for example: res/layout/ is good for anything, but res/layout-land/ is for landscape orientations.
In Android, almost everything is a resource. Defining resources that you can then access in your app is an essential part of Android development. Resources are used for anything from defining colors, images, layouts, menus, and string values. The value of this is that nothing is hardcoded.
In Android, a resource is a localized text string, bitmap, layout, or other small piece of noncode information that your app needs. At build time, all resources get compiled into your application. The resources locates inside res directory of your app.
use http://developer.android.com/reference/android/content/res/Configuration.html
example for dpi:
Configuration config = getResources().getConfiguration();
Log.d("DPI ", Integer.toString(config.densityDpi));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With