1

Am trying to update a data in my SQLite database buts it crashing in EditQuickin Class any idea or solution will be welcomed

    (QuickinModel)getIntent().getSerializableExtra(Quickin.QUICKIN_EXTRA);

    db = new DbController(this);


    FloatingActionButton fab = findViewById(R.id.fab);
    FullName = findViewById(R.id.FullNameEdit);
    DgnNumber = findViewById(R.id.DgnEdit);

    Save = findViewById(R.id.btnSave);
    spinStatus = findViewById(R.id.spinner);

    FullName.setText(quickinModel.getFullName());
    DgnNumber.setText(quickinModel.getDgnNumber());

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

            String status = spinStatus.getSelectedItem().toString();

            db.update(Integer.parseInt(quickinModel.getId()), status);

            Toast.makeText(EditQuickin.this, "Updated Successfully", Toast.LENGTH_SHORT).show();
            Intent i = new Intent(getApplicationContext(), Quickin.class);
            startActivity(i);

        }
    });

This is the Error am seeing

Process: codes.dgn.dgn, PID: 26567
java.lang.NumberFormatException: Invalid int: "null"
1

1 Answer 1

0

Seems like the problem is in Integer.parseInt(quickinModel.getId()) check if quickinModel.getId() returns value

Sign up to request clarification or add additional context in comments.

2 Comments

i have check it still could not figure it out, can you explain more
Its not clear from your code how values are assigned in your quickinModel object. id field in quickinModel is assigned with null. So, in Integer.parseInt(quickinModel.getId()) its passing null as parameter and generating NumberFormatException

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.