本文整理汇总了Java中org.litepal.crud.DataSupport.updateAll方法的典型用法代码示例。如果您正苦于以下问题:Java DataSupport.updateAll方法的具体用法?Java DataSupport.updateAll怎么用?Java DataSupport.updateAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.litepal.crud.DataSupport
的用法示例。
在下文中一共展示了DataSupport.updateAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUpdateAllWithStaticUpdate
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testUpdateAllWithStaticUpdate() {
Student s;
int[] ids = new int[5];
for (int i = 0; i < 5; i++) {
s = new Student();
s.setName("Dusting");
s.setAge(i + 10);
s.save();
ids[i] = s.getId();
}
ContentValues values = new ContentValues();
values.put("age", 24);
int affectedRows = DataSupport.updateAll(Student.class, values, "name = ? and age = ?",
"Dusting", "13");
assertEquals(1, affectedRows);
Student updatedStu = getStudent(ids[3]);
assertEquals(24, updatedStu.getAge());
values.clear();
values.put("name", "Dustee");
affectedRows = DataSupport.updateAll(Student.class, values, "name = ?", "Dusting");
assertEquals(5, affectedRows);
List<Student> students = getStudents(ids);
for (Student updatedStudent : students) {
assertEquals("Dustee", updatedStudent.getName());
}
}
示例2: addToFavorite
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
private void addToFavorite(int position) {
Live t = liveList.get(position);
ContentValues values = new ContentValues();
Intent intent = new Intent("com.lalala.fangs.neutv.LIVE_FAVORITE_CHANGE");
if (t.getIsFavorite()) {
t.setIsFavorite(false);
values.put("isFavorite", "0");
} else {
t.setIsFavorite(true);
values.put("isFavorite", "1");
}
//更新数据库
DataSupport.updateAll(Live.class, values, "name = ?", t.getName());
intent.putExtra("live_name", t.getName());
intent.putExtra("live_favorite", t.getIsFavorite());
localBroadcastManager.sendBroadcast(intent);
adapter.update(position);
}
示例3: updateCity
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
private void updateCity(IFakeWeather weather) {
for (int i = 0; i < adapter.getData().size(); i++) {
if (weather.getFakeBasic().getCityName().equals(adapter.getItem(i).getCityName())) {
adapter.getItem(i).setWeatherCode(weather.getFakeNow().getNowCode());
adapter.getItem(i).setWeatherTemp(weather.getFakeNow().getNowTemp());
adapter.getItem(i).setWeatherText(weather.getFakeNow().getNowText());
adapter.notifyItemChanged(i);
ContentValues values = new ContentValues();
values.put("weatherCode", weather.getFakeNow().getNowCode());
values.put("weatherText", weather.getFakeNow().getNowText());
values.put("weatherTemp", weather.getFakeNow().getNowTemp());
DataSupport.updateAll(WeatherCity.class, values, "cityName = ?", weather.getFakeBasic().getCityName());
break;
}
}
}
示例4: testUpdateAllRowsWithStaticUpdate
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testUpdateAllRowsWithStaticUpdate() {
int allRows = getRowsCount(studentTable);
ContentValues values = new ContentValues();
values.put("name", "Zuckerburg");
int affectedRows = DataSupport.updateAll(Student.class, values);
assertEquals(allRows, affectedRows);
String table = DBUtility.getIntermediateTableName(studentTable, DBUtility.getTableNameByClassName(Teacher.class.getName()));
allRows = getRowsCount(table);
values.clear();
values.putNull(studentTable + "_id");
affectedRows = DataSupport.updateAll(table, values);
assertEquals(allRows, affectedRows);
}
示例5: updateGroupMemberPortraitUri
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public synchronized void updateGroupMemberPortraitUri(String userId, String portraitUri) {
if (TextUtils.isEmpty(portraitUri))
return;
ContentValues values = new ContentValues();
values.put("portraituri", portraitUri);
DataSupport.updateAll(GroupMember.class, values, "userid = ?", userId);
}
示例6: updateState
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public int updateState(String key, String select){
ContentValues values = new ContentValues();
values.put("isSelected", select);
return DataSupport.updateAll(GankTypeInfo.class,values,"key = ?",key);
}
示例7: moveToLast
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void moveToLast(String key){
GankTypeInfo last = DataSupport.order("order").findLast(GankTypeInfo.class);
ContentValues values = new ContentValues();
values.put("order", last.getOrder()+1);
DataSupport.updateAll(GankTypeInfo.class,values,"key = ?",key);
}