mardi 24 février 2015

Nullpointerexception when I try to update in android

I have a problem when I try to update a table. But the problem is not for sentence sql, is calling the method for update. This is the code of button that make the action



public void onClick(View v)
{
switch (v.getId())
{
case R.id.btnsave:
String id="Act1";
datos.Actualizar(id,punactfis);
Toast.makeText(MainProgreso.this, "Bien Hecho", Toast.LENGTH_SHORT).show();
datos.close();
}
}


the code method Actualizar



public void Actualizar(String id, int puntos)
{
Log.i("Variables", id);
String query="UPDATE Actividades SET puntos="+puntos+" ,total_puntos=total_puntos"+puntos+" WHERE id_actividad="+id+";";
Log.i("Consulta", query);
db.execSQL(query);
}


This is the log



02-24 15:07:00.474: E/AndroidRuntime(858): FATAL EXCEPTION: main 02-24 15:07:00.474: E/AndroidRuntime(858): java.lang.NullPointerException 02-24 15:07:00.474: E/AndroidRuntime(858): at com.example.app8semanas.MainProgreso.onClick(MainProgreso.java:133) 02-24 15:07:00.474: E/AndroidRuntime(858): at android.view.View.performClick(View.java:3480) 02-24 15:07:00.474: E/AndroidRuntime(858): at android.view.View$PerformClick.run(View.java:13983) 02-24 15:07:00.474: E/AndroidRuntime(858): at android.os.Handler.handleCallback(Handler.java:605) 02-24 15:07:00.474: E/AndroidRuntime(858): at android.os.Handler.dispatchMessage(Handler.java:92) 02-24 15:07:00.474: E/AndroidRuntime(858): at android.os.Looper.loop(Looper.java:137) 02-24 15:07:00.474: E/AndroidRuntime(858): at android.app.ActivityThread.main(ActivityThread.java:4340) 02-24 15:07:00.474: E/AndroidRuntime(858): at java.lang.reflect.Method.invokeNative(Native Method) 02-24 15:07:00.474: E/AndroidRuntime(858): at java.lang.reflect.Method.invoke(Method.java:511) 02-24 15:07:00.474: E/AndroidRuntime(858): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 02-24 15:07:00.474: E/AndroidRuntime(858): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 02-24 15:07:00.474: E/AndroidRuntime(858): at dalvik.system.NativeStart.main(Native Method)



thanks for your help.


Aucun commentaire:

Enregistrer un commentaire