pardom-zz / ActiveAndroid

Active record style SQLite persistence for Android
http://www.activeandroid.com
4.7k stars 1.03k forks source link

How i can delete all record in a table ? #532

Open qu4sar opened 7 years ago

qu4sar commented 7 years ago

How i can delete all record in a table ? i try with new Delete().from(MyClass.class); but nothing

havenvo commented 7 years ago

I created this function to clear all table records. public static void clearTable(Class<? extends Model> type) { TableInfo tableInfo = Cache.getTableInfo(type); ActiveAndroid.execSQL(String.format("DELETE FROM %s;", tableInfo.getTableName())); ActiveAndroid.execSQL( String.format("DELETE FROM sqlite_sequence WHERE name='%s';", tableInfo.getTableName())); }

Hope it helps.

hasnain-ahmad commented 4 years ago

How to delete one record from Table using Where Clause?