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
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.
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.