Android Studio Sqlite Import method delete error

0

You are not deleting the database table, Android Studio does not point to any errors when clicking the button the program does nothing

(NA ACTIVITY DatabaseHelper)   public void delete () {

    SQLiteDatabase db = getWritableDatabase();
    db.execSQL("DROP IF TABLE EXISTS mylist_data");
    onCreate(db);

}

(NA ACTIVITY MainActivity) (On) public class MainActivity extends AppCompatActivity {

DatabaseHelper myDB;
Button button, button4, button2, button5;
EditText editText, editText2, editText3, editText4;

(Below the time to call the method)

button2.setOnClickListener (new View.OnClickListener () {             @Override             public void onClick (View v) {

        myDB.delete();
    
asked by anonymous 21.05.2017 / 19:04

1 answer

0

I did not test your code but looking at:

db.execSQL("DROP IF TABLE EXISTS mylist_data");

It looks like you're putting FI before TABLE.

The correct one would be:

db.execSQL("DROP TABLE IF EXISTS mylist_data");

    
22.05.2017 / 01:05