我的代码中出现以下错误可能是我遗漏了一些东西,我有另一个具有相同类型的代码并且工作正常:java.lang.NullPointerException: 尝试调用虚拟方法'long app.akexorcist.bluetoothspp.DatabaseHelper.insertData(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang .String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)' 在一个空对象上参考以下是一些代码:谢谢public void postDataToSQLite() { SharedPreferences sharedpreferences = getSharedPreferences(LoginActivity.MyPREFERENCES, Context.MODE_PRIVATE); SharedPreferences.Editor 编辑器 = sharedpreferences.edit(); SharedPreferences vehiclesharedpreferences = getSharedPreferences(VehicleEntryActivity.MyVehicle, Context.MODE_PRIVATE); SharedPreferences.Editor vehicle_editor = sharedpreferences.edit(); String name = txtName.getText().toString(); String surname = txtSurname.getText().toString(); String idno = txtIDNo.getText().toString(); String birth = txtDateBirth.getText().toString(); String username = sharedpreferences.getString(Name, ""); editor.apply(); String make = vehiclesharedpreferences.getString(Make, ""); String colour = vehiclesharedpreferences.getString(Colour, ""); String expiry = vehiclesharedpreferences.getString(Expiry, ""); String regno = vehiclesharedpreferences.getString(RegNo, ""); String date = vehiclesharedpreferences.getString(DateTime, ""); String loc = vehiclesharedpreferences.getString(GPS, ""); vehicle_editor.apply(); String event = "Entry"; if(name.isEmpty() || surname.isEmpty() || idno.isEmpty() || birth.isEmpty()) { Toast.makeText(this, "Please scan drivers licence", Toast.LENGTH_SHORT).show(); } else { long id = helper.insertData(make,colour,expiry,regno,date,loc,name,surname,idno,birth,event,username); Intent intent = null; if(id<=0) { Message.message(getApplicationContext(),"Failed... Please Check Data"); }
添加回答
举报
0/150
提交
取消