mercredi 24 février 2016

Issue when deleting top 18000 rows from SQLite (Android)

I have a database for my Android app which is created as such:

String CREATE_TABLE_GYRO = "CREATE TABLE gyro ( " +
                "id INTEGER PRIMARY KEY AUTOINCREMENT, " +
                "timestamp BIGINT NOT NULL, " +
                "x FLOAT NOT NULL, " +
                "y FLOAT NOT NULL, " +
                "z FLOAT NOT NULL)";

I want to delete the first 18000 entries in my database. I do this using the following code and query:

SQLiteDatabase database = this.getWritableDatabase();
System.out.println("Database size before delete: " + getSize());
database.rawQuery("DELETE FROM gyro WHERE id IN(SELECT id FROM gyro ORDER BY id ASC LIMIT 18000)", null);
System.out.println("Database size after delete: " + getSize());

However, nothing appears to happen. Here is the output:

Database size before delete: 10665984
Database size after delete: 10665984

Where am I going wrong?

Aucun commentaire:

Enregistrer un commentaire