Data object stores properly, but object in callback is a blank / default constructor object

I’m trying to create the simplest app that can store and retrieve data. I’ve created Comment class to be the type of data stored:

public class Comment {
private String Message;
private String authorEmail;
public Comment() {
this.Message = "Default message";
}
public String getMessage() {
return Message;
}
public void setMessage(String message) {
this.Message = message;
}
public String getAuthorEmail() {
return authorEmail;
}
public void setAuthorEmail(String authorEmail) {
this.authorEmail = authorEmail;
}
}

When I touch the Submit button, the app properly stores a Comment object in the Backendless Comment table. The Message field’s data appears as expected, while the authorEmail always shows up as the default literal I specify in the code. But I don’t get real data back from backendless. Only default constructor objects.

public class MainActivity extends AppCompatActivity {
EditText mComment;
Button bSubmit;
Button bRetrieve;
TextView status;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String appID = "_my_app_id_";
String secretKey = "_my_secret_key_";
Backendless.initApp(this,appID,secretKey,"v1");
mComment = (EditText) findViewById(R.id.etComment);
bSubmit = (Button) findViewById(R.id.bSubmit);
bRetrieve = (Button) findViewById(R.id.bRetrieve);
status = (TextView) findViewById(R.id.status);
bSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Comment comment = new Comment();
comment.setMessage(mComment.getText().toString());
Log.i("Comments",comment.getMessage());
comment.setAuthorEmail("generic@domain.com");
Backendless.Persistence.save(comment, new AsyncCallback<Comment>()
{
@Override
public void handleResponse(Comment comment) {
Log.i("Comments", "New comment saved");
status.setText("New comment saved: "+comment.getMessage());
mComment.setText("");
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
Log.i("Fault", backendlessFault.toString());
}
} );
}
});
bRetrieve.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Backendless.Persistence.of(Comment.class).find(
new AsyncCallback<BackendlessCollection<Comment>>() {
@Override
public void handleResponse(BackendlessCollection<Comment> data) {
status.setText(data.getData().get(0).getMessage());
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
Log.i("Retrieve",backendlessFault.toString());
}
}
);
}
});
}
}

The data stores properly in the online table. However, the Comment objects I get back from the callback functions are always just a default constructor file instead of real data from backendless. The message is always “Default message” that I specified as the default value in the Comment() no argument constructor method. This is true in the callback for both handleResponse() methods used above(Persistence.save and for Persistence.find).
To be specific, my “Retrieve” button onClick method works, but it always changes my status TextView’s text to “Default message” instead of whatever the first Comment’s actual Message is. And when I hit the “Submit” button, it always says “New comment saved: Default message” instead of whatever it is that I had typed into my EditText.

How can I troubleshoot this issue?

FYI, I got the SDK by copying backendless.jar, version 3.0.21, into my app/libs folder. I was having issues doing it via maven dependency.

Hi Dan,

Could you please let me know your app id?

Regards,
Mark

App ID is the following:

36B067E1-F470-1927-FFE8-C99EF45CAA00

Hi Dan,

try changing the “Message” private field to “message”, like this:
private String message;

Rebuild the code and try again.

Let me know if it helped.

Regards,
Mark

Yes, that worked. Is lowercase first character a requirement for field names?

Yes, with the version of the SDK you use, the capitalization of the field names must match the names of the columns in your data tables.

Ok. I didn’t realize the table online was lower case. Thanks very much for helping with my silly issue.