MCPcopy Index your code
hub / github.com/Sopage/android-orm / update

Method update

library/src/main/java/com/sanders/db/DBProxy.java:138–159  ·  view source on GitHub ↗

更具条件更新实体到数据库 @param t @param where @param args @param @return

(T t, String where, String... args)

Source from the content-addressed store, hash-verified

136 * @return
137 */
138 public final <T extends IDColumn> int update(T t, String where, String... args) {
139 if (t == null) {
140 throw new NullPointerException("更新对象为NULL!");
141 }
142 if (where == null || where.trim().length() < 1) {
143 throw new NullPointerException("缺少WHERE条件语句!");
144 }
145 ClassInfo<T> classInfo = getClassInfo(t);
146 String tableName = classInfo.getTableName();
147 ContentValues values = classInfo.getContentValues(t);
148 if (values.size() < 1) {
149 return -1;
150 }
151 values.remove(IDColumn.PRIMARY_KEY);
152 SQLiteDatabase database = getDatabase();
153 database.beginTransaction();
154 int row = database.update(tableName, values, where, args);
155 database.setTransactionSuccessful();
156 database.endTransaction();
157 close(database);
158 return row;
159 }
160
161 /**
162 * 更新表数据

Callers 1

insertOrUpdateMethod · 0.95

Calls 7

getClassInfoMethod · 0.95
getDatabaseMethod · 0.95
closeMethod · 0.95
isEmptyMethod · 0.95
getTableNameMethod · 0.80
getContentValuesMethod · 0.80
getPrimaryKeyMethod · 0.80

Tested by

no test coverage detected