Android examples for java.lang.reflect:Field Name
get All Fields from a Class
//package com.java2s; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static List<Field> getAllFields(Class clazz) { List<Field> results = new ArrayList<Field>(); Class superClass = clazz; while (superClass != Object.class) { results.addAll(Arrays.asList(superClass.getFields())); results.addAll(Arrays.asList(superClass.getDeclaredFields())); superClass = superClass.getSuperclass(); }//ww w.ja v a 2 s . c o m return results; } }