ppamorim

Untitled

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