Android Open Source - SimpleStorage S Q L Helper






From Project

Back to project page SimpleStorage.

License

The source code is released under:

Apache License

If you think the Android project SimpleStorage listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.njzk2.simplestorage;
/*  www. j  a va  2 s  . co m*/
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class SQLHelper {
  private static Map<Class<?>, Field[]> fields = new HashMap<Class<?>, Field[]>();

  static Field[] getFields(Class<? extends Storable> clazz) {
    if (!fields.containsKey(clazz)) {
      Collection<Field> fs = new ArrayList<Field>();
      for (Field field : clazz.getDeclaredFields()) {
        if (!Modifier.isStatic(field.getModifiers())) {
          fs.add(field);
        }
      }
      fields.put(clazz, fs.toArray(new Field[0]));
    }
    return fields.get(clazz);
  }

  public static String getTableName(Class<? extends Storable> clazz) {
    return clazz.getSimpleName();
  }
}




Java Source Code List

com.njzk2.simplestorage.DataProvider.java
com.njzk2.simplestorage.Database.java
com.njzk2.simplestorage.SQLHelper.java
com.njzk2.simplestorage.SQLSchema.java
com.njzk2.simplestorage.Storable.java
com.njzk2.simplestorage.handler.BooleanHandler.java
com.njzk2.simplestorage.handler.BytesHandler.java
com.njzk2.simplestorage.handler.DateHandler.java
com.njzk2.simplestorage.handler.IntHandler.java
com.njzk2.simplestorage.handler.LongHandler.java
com.njzk2.simplestorage.handler.StringArrayHandler.java
com.njzk2.simplestorage.handler.StringHandler.java
com.njzk2.simplestorage.handler.TypeHandler.java