MCPcopy Create free account
hub / github.com/androrm/androrm / delete

Method delete

src/src/com/orm/androrm/Model.java:411–427  ·  view source on GitHub ↗
(Context context)

Source from the content-addressed store, hash-verified

409 }
410
411 public <T extends Model> boolean delete(Context context) {
412 if(getId() != 0) {
413 Where where = new Where();
414 where.and(PK, getId());
415
416 DatabaseAdapter adapter = DatabaseAdapter.getInstance(context);
417 int affectedRows = adapter.delete(DatabaseBuilder.getTableName(getClass()), where);
418
419 if(affectedRows != 0) {
420 mId.set(0);
421
422 return resetFields();
423 }
424 }
425
426 return false;
427 }
428
429 private <T extends Model> boolean resetFields() {
430 List<Field> fields = DatabaseBuilder.getFields(getClass(), this);

Callers 5

testDeleteMethod · 0.45
testDoCascadeMethod · 0.45
testDoNotCascadeMethod · 0.45
testResetMethod · 0.45
testResetMethod · 0.45

Calls 7

getIdMethod · 0.95
andMethod · 0.95
getInstanceMethod · 0.95
deleteMethod · 0.95
getTableNameMethod · 0.95
resetFieldsMethod · 0.95
setMethod · 0.65

Tested by 5

testDeleteMethod · 0.36
testDoCascadeMethod · 0.36
testDoNotCascadeMethod · 0.36
testResetMethod · 0.36
testResetMethod · 0.36