本文整理匯總了Java中org.litepal.crud.DataSupport.update方法的典型用法代碼示例。如果您正苦於以下問題:Java DataSupport.update方法的具體用法?Java DataSupport.update怎麽用?Java DataSupport.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.litepal.crud.DataSupport
的用法示例。
在下文中一共展示了DataSupport.update方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testUpdateBlobWithStaticUpdate
import org.litepal.crud.DataSupport; //導入方法依賴的package包/類
public void testUpdateBlobWithStaticUpdate() {
byte[] b = new byte[10];
for (int i = 0; i < b.length; i++) {
b[i] = (byte)i;
}
Product product = new Product();
product.setBrand("Android");
product.setPrice(2899.69);
product.setPic(b);
assertTrue(product.saveFast());
for (int i = 0; i < b.length; i++) {
b[i] = (byte) (b.length - i);
}
ContentValues values = new ContentValues();
values.put("pic", b);
int rows = DataSupport.update(Product.class, values, product.getId());
assertEquals(1, rows);
Product p = DataSupport.find(Product.class, product.getId());
byte[] pic = p.getPic();
assertEquals(b.length, pic.length);
for (int i = 0; i < b.length; i++) {
byte a = (byte) (b.length - i);
assertEquals(a, pic[i]);
}
}
示例2: testUpdateWithStaticUpdate
import org.litepal.crud.DataSupport; //導入方法依賴的package包/類
public void testUpdateWithStaticUpdate() {
ContentValues values = new ContentValues();
values.put("TEACHERNAME", "Toy");
int rowsAffected = DataSupport.update(Teacher.class, values, teacher.getId());
assertEquals(1, rowsAffected);
assertEquals("Toy", getTeacher(teacher.getId()).getTeacherName());
values.clear();
values.put("aGe", 15);
rowsAffected = DataSupport.update(Student.class, values, student.getId());
assertEquals(1, rowsAffected);
assertEquals(15, getStudent(student.getId()).getAge());
}
示例3: testUpdateWithStaticUpdateButWrongClass
import org.litepal.crud.DataSupport; //導入方法依賴的package包/類
public void testUpdateWithStaticUpdateButWrongClass() {
ContentValues values = new ContentValues();
values.put("TEACHERNAME", "Toy");
try {
DataSupport.update(Object.class, values, teacher.getId());
} catch (SQLiteException e) {
}
}
示例4: testUpdateWithStaticUpdateButWrongColumn
import org.litepal.crud.DataSupport; //導入方法依賴的package包/類
public void testUpdateWithStaticUpdateButWrongColumn() {
ContentValues values = new ContentValues();
values.put("TEACHERYEARS", 13);
try {
DataSupport.update(Teacher.class, values, teacher.getId());
fail("no such column: TEACHERYEARS");
} catch (SQLiteException e) {
}
}
示例5: testUpdateWithStaticUpdateButNotExistsRecord
import org.litepal.crud.DataSupport; //導入方法依賴的package包/類
public void testUpdateWithStaticUpdateButNotExistsRecord() {
ContentValues values = new ContentValues();
values.put("TEACHERNAME", "Toy");
int rowsAffected = DataSupport.update(Teacher.class, values, 998909);
assertEquals(0, rowsAffected);
}