public enum ResourceAccessibility extends java.lang.Enum<ResourceAccessibility>
Public accessibility.
A resource can be marked as public by adding the public element to a values XML file:
<public name="my_public_string" type="string"/>.
These elements are usually defined in the public.xml file inside the res/values directory.
Private accessibility.
Sometimes a libraries can have a great number of resources and it might be confusing or
tiresome to find the correct one when writing the Java or Kotlin code. In order to restrict the
resources visible from the source code, one can list the only resources they want to be visible
by using the java-symbol element:
<java-symbol name="my_visible_string" type="string/>.
These elements are usually defined in the symbols.xml file inside the res/values directory. The name private comes from these resources being present in the
private R.java along with public resources.
Default accessibility.
All resources that were not marked as public or private have the default accessibility.
Usage.
In order to generate a public R.java containing only the public resources and a private R.java
containing both public and private resources, specify the package for the private R.java in the
build.gradle file. For example, if the application's package (or the custom package) is
com.foo.bar you could use com.foo.bar.symbols for the private R.java:
android {
...
aaptOptions {
privateRDotJavaPackage "com.foo.bar.symbols"
}
}
Without the package for the private R.java specified, only the public R.java will be generated and it will contain all resources (ones marked as public, java-symbol and those not marked as either).
| Modifier and Type | Method and Description |
|---|---|
static ResourceAccessibility |
getEnum(java.lang.String qualifier) |
java.lang.String |
getName() |
static ResourceAccessibility |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static ResourceAccessibility[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ResourceAccessibility DEFAULT
public static final ResourceAccessibility PRIVATE
public static final ResourceAccessibility PUBLIC
public static ResourceAccessibility[] values()
for (ResourceAccessibility c : ResourceAccessibility.values()) System.out.println(c);
public static ResourceAccessibility valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic java.lang.String getName()
public static ResourceAccessibility getEnum(@NonNull java.lang.String qualifier)