Milos Cuculovic
Milos Cuculovic

Reputation: 20223

Clean (remove all from) the table on Android

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

Answers (3)

FabianCook
FabianCook

Reputation: 20587

Do something like this

public boolean deleteAll(){

        return mDb.delete(DATABASE_TABLE, "1", null) > 0;

    }

Upvotes: 3

harmjanr
harmjanr

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

Tim
Tim

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

Related Questions