Error getting data from table || Android

Hello
I’m saving data to table "Messages " using that code :

Messages message = new Messages();
message.setUser(current_name);
message.setMessageText(messageText);
message.setPhoto_URL(current_photo_URL);
Backendless.Persistence.save(message, new AsyncCallback<Messages>() {
@Override
public void handleResponse(Messages messages) {
editmessage.setText("");
progressDialog.dismiss();
refresh();
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
Toast.makeText(getApplicationContext(),backendlessFault.getMessage(),Toast.LENGTH_LONG).show();
progressDialog.dismiss();
}
});

And I’m retrieving a specific row from it … using findById method :

Messages message = UsersMessages.get(position);
if(message != null ){
Toast.makeText(MainActivity.this,"not null",Toast.LENGTH_SHORT).show();
}
Backendless.Persistence.of(Messages.class).findById(message
, new AsyncCallback<Messages>() {
@Override
public void handleResponse(final Messages message) {
messageId = message.getObjectId();
if(messageId != null){
Toast.makeText(MainActivity.this," id not null",Toast.LENGTH_SHORT).show();
} 

and as you see I 'm checking if the objectId of the message(Row in" Messages "Table) is null using a toast but the toast isn’t showing so that mean the objectId is null … but after that I’m checking the “messageText” column :

messagetext = message.getMessageText();
if(messagetext != null){
Toast.makeText(MainActivity.this," text not null",Toast.LENGTH_SHORT).show();
}
messageUser = message.getUser();
if(messageUser != null){
Toast.makeText(MainActivity.this,"user name not null",Toast.LENGTH_SHORT).show();
}

but they aren’t null … that means the problem is in the objectId not in the message object

When you call this method:

Backendless.Persistence.of(Messages.class).findById

The first argument must be object ID of the message you need to retrieve. In your code, it is the Messages object, which is wrong.

Yeah I forgot that … I’ll try

‘Id cannot be null or empty .’ that the error showing

Have you checked whether your Message object has a non-null and non-empty objectId?

The error message tells you exactly what the problem is.

the problem is that the objectId in the message object in is null right ?

Then why only objectId is null but the others columns like messageText and messageUser aren’t null?!

the problem is when you look for an object by ID, you need to provide a valid ID into the findByID method. The argument cannot be null or empty string.

For this question:

Then why only objectId is null but the others columns like messageText and messageUser aren't null?!

I’d like you to narrow down the code where this happens and ask again. There’s just way too much wrong code there that makes it harder to answer your question.

Look in my table the objectId isn’t null

I’ve send a photo but it seems like it hasn’t been sent

Your best friend is Mr. Debugger right now…

hhhh you’re right !!

Please I’ve a question : what’s the difference between getData() method and getCurrentPage() method ?

I 'm using the second method to get the data from messages table … is that wrong ?

There is no difference between the methods - they return the same data.