我想通过填写表单将数据插入到 sqlite 数据库表中的一行,当我单击提交按钮时出现错误。这是一段代码和logcat
public void callDialogConfirmation(){
AlertDialog.Builder confirm = new AlertDialog.Builder(Form.this);
confirm.setTitle("Please Confirm");
confirm.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
String inputanSavings = spinner1.getSelectedItem().toString();
String tglmsk = spinner2.getSelectedItem().toString();
SharedPreferences.Editor editor = someData.edit();
editor.putString("sharedString1", inputanSavings);
editor.putString("sharedString2", tglmsk);
editor.commit();
String inputSalary = salary.getText().toString();
dbHelper.createIncome("Routine Income",inputSalary);
Intent openStartingPoint = new Intent(Form.this, MainActivity.class);
startActivity(openStartingPoint);
}});
这是插入数据的方法
public long createIncome(String l, String n) {
ContentValues initialValues = new ContentValues();
initialValues.put(RLPE, l);
initialValues.put(RNPE, n);
initialValues.put(RBPE, m); // The m is the current date with Calendar library
return mDbP.insert(INCOME_TABLE, null, initialValues);
}
这是我单击“提交”按钮后立即收到的错误
07-21 22:00:39.234: E/AndroidRuntime(971): FATAL EXCEPTION: main
07-21 22:00:39.234: E/AndroidRuntime(971): java.lang.NullPointerException
07-21 22:00:39.234: E/AndroidRuntime(971): at com.diarykeuanganmahasiswa.dkm.Form$1.onClick(Form.java:64)
07-21 22:00:39.234: E/AndroidRuntime(971): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159)
07-21 22:00:39.234: E/AndroidRuntime(971): at android.os.Handler.dispatchMessage(Handler.java:99)
07-21 22:00:39.234: E/AndroidRuntime(971): at android.os.Looper.loop(Looper.java:123)
07-21 22:00:39.234: E/AndroidRuntime(971): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-21 22:00:39.234: E/AndroidRuntime(971): at java.lang.reflect.Method.invokeNative(Native Method)
07-21 22:00:39.234: E/AndroidRuntime(971): at java.lang.reflect.Method.invoke(Method.java:507)
07-21 22:00:39.234: E/AndroidRuntime(971): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-21 22:00:39.234: E/AndroidRuntime(971): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-21 22:00:39.234: E/AndroidRuntime(971): at dalvik.system.NativeStart.main(Native Method)
任何人都知道似乎是什么问题?请帮忙,谢谢