1.这是反射过程
@Override
protected String createTable(String tableName,Class bean) {
Field[] fields= bean.getDeclaredFields();
StringBuilder stringBuilder =new StringBuilder();
stringBuilder.append("create table if not exists "+tableName+" ( ");
for (int i = 0; i <fields.length ; i++) {
TLog.error(fields[i].getName());
if (i==fields.length-1){
stringBuilder.append(" "+fields[i].getName()+" varchar(40)");
}else {
stringBuilder.append(" "+fields[i].getName()+" varchar(40),");
}
}
stringBuilder.append(" );");
return stringBuilder.toString();
}
2.这是反射的bean对象
public class City {
public City(String id, String name, String cityCode) {
this.id = id;
this.name = name;
this.cityCode = cityCode;
}
public String id;
public String name;
public String cityCode;
}
3.这是log日志
01-11 10:16:17.467 5631-5631/com.ccj.archdesigns E/TLog: cityCode
01-11 10:16:17.467 5631-5631/com.ccj.archdesigns E/TLog: id
01-11 10:16:17.467 5631-5631/com.ccj.archdesigns E/TLog: name
01-11 10:16:17.467 5631-5631/com.ccj.archdesigns E/TLog: $change
01-11 10:16:17.467 5631-5631/com.ccj.archdesigns E/TLog: serialVersionUID
是因为AndroidStudio里InstantRun的问题,关闭这个功能就不会出现那个$change了:
好像只有在Android Studio2.1里会出现这个情况,在Android Studio2.2.3 里没有这个情况。google似乎修改了这个bug,https://code.google.com/p/and...