Error in sqlite

2

I am working on android studio with database sqlite and it generates the following error when deleting all the data in a table:

When using this code:

db.delete("tabla",null,null);

I get the following error:

  

android.database.sqlite.SQLiteException: near "*": syntax error (code 1):, while compiling: DELETE * FROM table

    
asked by Pulga 14.09.2016 в 22:48
source

2 answers

1

I do not think that the line you describe is the problem because it would work without problem using the delete () :

db.delete(TABLE_NAME, null, null);

In another part of your code you should be using the execSQL () , in which you define a string with the query:

 db.execSQL("DELETE *FROM tabla");

and you do not have a space defined before FROM , you must correct.

 db.execSQL("DELETE * FROM tabla");
    
answered by 14.09.2016 в 23:43
0

The asterisk is pasted to the word FROM . Your query must be DELETE * FROM tabla; .

    
answered by 14.09.2016 в 22:50