mercredi 4 novembre 2015

Initialize long value which was get from other activity

I get a long value from other activity and want to save it in sqlite.

long a;
a= bundle.getLong("foreignKey"); // value ab get from other activities
k.insertToDB(a);

I know I have to initialize a since it might pointing towards null, but how can I do to fix this?

java.lang.NullPointerException: Attempt to invoke virtual method 'long com.example.project.project.API.StaffAPI.insertStaffBenefit(java.lang.String, java.lang.String, long)' on a null object reference

Aucun commentaire:

Enregistrer un commentaire