null object Reference

null object reference error on my userId

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.String com.backendless.BackendlessUser.getUserId()’ on a null object reference

Hi Nomfundo

looks like you try to get userId of undefined user, don’t you?
could you try this

if(Backendless.UserService.CurrentUser() != null)

   String userId = Backendless.UserService.CurrentUser().getUserId()

Regards, Vlad

im trying to edit information viewed on the list view

view.txt (3.6kB)

did you try to add “IF” condition in place where the error occurs?


please share with us a minimal (not all file) code snippet where the problem occurs and we will look into it.

Vladimir asks you to show a minimal code to reproduce a problem, do not list all your code in the topic

String whereClause = “ownerId = '” + Backendless.UserService.CurrentUser().getProperty(“objectId”)+"’";

errorCaused by: java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.Object com.backendless.BackendlessUser.getProperty(java.lang.String)’ on a null object reference
at com.example.hellen.xchngeinvestmenttraining.AdminAppointment.buttAppoint(

are you sure that Backendless.UserService.CurrentUser() isn’t “null” ?

yes because its showing the list view but not the right person when im suppose to edit

Hello Nomfundo,

please share your APP ID and the part of code to reproduce this issue. What are you doing before this part of code?

String whereClause = "ownerId = '" + Backendless.UserService.CurrentUser().getProperty("objectId")+"'";

Regards, Olga