本文整理匯總了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);
}