Android examples for java.lang.reflect:Field Private
get Private Fields from a class
//package com.java2s; import android.support.annotation.NonNull; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; public class Main { public static List<Field> getPrivateFields(@NonNull Class clazz) { List<Field> fields = new ArrayList<>(); for (Field field : clazz.getDeclaredFields()) { if (Modifier.isPrivate(field.getModifiers())) { fields.add(field);//from w w w .j av a 2 s . c o m } } return fields; } }