1
I’m making a database program. I wish I had the option to delete a data from database Sqlite. So here’s what I did:
In my OpenHelper
called the following method:
public void delete (){
SQLiteDatabase db = getWritableDatabase();
db.execSQL("DELETE FROM CLIENTE");
db.close();
}
Where CLIENT is the name of my table. Hence I created the method:
public void deletar (View view){
Dados_familiaOpenHelper dados_familiaOpenHelper = new Dados_familiaOpenHelper(null);
dados_familiaOpenHelper.delete();
}
This method is in a activity
that contains a button. This button onClick
and redirects to this method.
Dai ok. When I run my program, and click on the button, the app closes. Anyone has any advice or anything that can help me?
@EDIT
My Openhelper class:
public class Dados_familiaOpenHelper extends SQLiteOpenHelper {
public Dados_familiaOpenHelper(Context context){
super(context, "Dados_familia", null, 4);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(ScriptDLL.getCreateTableCliente() );
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
public void delete (){
SQLiteDatabase db = getWritableDatabase();
db.execSQL("DELETE FROM CLIENTE");
db.close();
}
Only with this information is not possible to know for sure, but the cause may be due to the passing
null
to the builder ofDados_familiaOpenHelper
.– ramaral
I’m half lost, still learning. What I should pass as a builder in Dados_familiaopenhelper?
– Ulivai
Put the question to the class
Dados_familiaOpenHelper
– Costamilam
I put the Dados_familiaopenhelper class.
– Ulivai
Anyone? Any ideas? kkk
– Ulivai
Error appears in logcat?
– Leonardo Lima