Delete all values in SQLite Table

Hello,

I am working on my first Xamarin Cross Platform App with Visual Studio.

For SQLite I am using sqlite-net-pcl.
I am using async methods.

How can I delete all entries in a table? For delete I just find

await conn.DeleteAsync(object);

Do I have to run through all values to delete them all?

Best Answers

  • LaireLaire DE
    Accepted Answer

    @JohnMiller

    I accept the answer because it bring me to the right solution:

    conn.ExecuteAsync("DELETE FROM TableName")

Answers

  • LaireLaire DEMember
    Accepted Answer

    @JohnMiller

    I accept the answer because it bring me to the right solution:

    conn.ExecuteAsync("DELETE FROM TableName")

  • RavinderJangraRavinderJangra USMember ✭✭✭

    And how did you achieve that, means deleting all the rows?

  • DFoulkDFoulk USMember ✭✭✭

    You can also drop the table, then recreate it (if you don't have other tables that use the IDs from the table):

    _database.DropTableAsync<Aircraft>().Wait();
    _database.CreateTableAsync<Aircraft>().Wait();
    

    This option should only be used if you (like me) are performing a "reset" of the data.

  • IvanFranchiIvanFranchi USMember ✭✭

    What about this? Does it have any cons? db.Table.Delete(x => x != null)

Sign In or Register to comment.