Java tutorial
//package com.java2s; import android.util.Log; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; public class Main { public static final String TAG = "HELPERS"; public static String[] getClassStaticFieldNames(Class c, Type fieldType, String nameContains) { Field[] fields = c.getDeclaredFields(); List<String> list = new ArrayList<>(); for (Field field : fields) { try { boolean isString = field.getType().equals(fieldType); boolean containsExtra = field.getName().contains(nameContains); boolean isStatic = Modifier.isStatic(field.getModifiers()); if (field.getType().equals(String.class) && field.getName().contains("EXTRA_") && Modifier.isStatic(field.getModifiers())) list.add(String.valueOf(field.get(null))); } catch (IllegalAccessException iae) { Log.d(TAG, "!!!!!!!!!!!! class Static field, illegal access exception message: " + iae.getMessage()); } } return list.toArray(new String[list.size()]); } }