Android examples for android.accounts:Account
Returns COLUMN_ fields from contract obj.
//package com.java2s; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; public class Main { /**/*from w w w . j av a2 s . co m*/ * Returns COLUMN_ fields from contract obj. * @param contract Database contract class. */ public static List<String> getColumns(Class contract) { List<String> columns = new ArrayList<>(); Field[] allFields = contract.getFields(); for (Field f : allFields) { final int m = f.getModifiers(); if (Modifier.isPublic(m) && Modifier.isStatic(m) && Modifier.isFinal(m) && f.getName().startsWith("COLUMN_")) { try { columns.add((String) f.get(contract)); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } } } return columns; } }