ppamorim

Untitled

Sep 13th, 2014
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. public abstract class BaseModel extends Model {
  2.  
  3.     public static final String _RID = "remote_id";
  4.  
  5.     public int getRemoteId() {
  6.         return -1;
  7.     }
  8.  
  9.     //Isso é usado para limpar o banco, truncate. Class<? extends Model> é uma classe que extende model.
  10.     public static void truncate(Class<? extends Model> type) {
  11.         try {
  12.  
  13.             TableInfo tableInfo = Cache.getTableInfo(type);
  14.             ActiveAndroid.execSQL("delete from " + tableInfo.getTableName() + ";");
  15.             ActiveAndroid.execSQL("delete from sqlite_sequence where name='" + tableInfo.getTableName() + "';");
  16.  
  17.         } catch (Exception e) {
  18.             e.printStackTrace();
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment