Reputation: 20223
Could you please tell me how to make a fonction on Android which will delate all what i have in my table named user.
Could I do do this with the SQLiteOpenHelper class and if yes, then how?
Thank you.
Upvotes: 2
Views: 1678
Reputation: 20587
Do something like this
public boolean deleteAll(){
return mDb.delete(DATABASE_TABLE, "1", null) > 0;
}
Upvotes: 3
Reputation: 937
You can clear a table from your database with:
db.delete("user", null, null);
The "delete" function will clear your table.
Upvotes: 1
Reputation: 6712
use this:
db.execSQL("DROP TABLE IF EXISTS TABLENAME");
db is an instance of SQLiteDatabse: http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#execSQL(java.lang.String)
Upvotes: 2