Wednesday, February 26, 2014

How to get all resource id from application in adnroid

How to get all resource id from application in android

This post about how to get all resource id from the application .

From R.id class you can get list of resource id.
  final R.id idResources = new R.id();
              final Class<R.id> c = R.id.class;
              final java.lang.reflect.Field[] fields = c.getDeclaredFields();
      

              for (int i = 0, max = fields.length; i < max; i++) {
                  final int resourceId;
                  try {
                      resourceId = fields[i].getInt(idResources);

Here all resource id will print in console
                      Log.e("ID", "resourceid :: " +resourceId);
             
                  } catch (Exception e) {
                      continue;
                  }
                 
              }

 

Full Source Code
public void chekResourceIDFound( int id){
final R.id idResources = new R.id();
final Class<R.id> c = R.id.class;
final java.lang.reflect.Field[] fields = c.getDeclaredFields();

for (int i = 0, max = fields.length; i < max; i++) {
final int resourceId;
try {
resourceId = fields[i].getInt(idResources);
Log.e("ID", "resourceid :: " +resourceId);

} catch (Exception e) {
continue;
}

}

}

              

No comments:

Post a Comment

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...