Backendless event does not fire - java

In my Android app I use Backendless to store my data online. I want to do something when a new Point object is saved but the beforeCreate event never gets triggered.
Bootstrap.java
public class Bootstrap implements IBackendlessBootstrap
{
#Override
public void onStart()
{
Backendless.setUrl( "https://api.backendless.com" );
Backendless.initApp( "XXXXXXXXXXXXXXXX", "XXXXXXXXXXXXX","v1");
Backendless.Persistence.mapTableToClass( "Point", Point.class );
}
#Override
public void onStop()
{
}
}
PointTableEventHandler.java:
#Asset( "Point" )
public class PointTableEventHandler extends com.backendless.servercode.extension.PersistenceExtender<Point>
{
#Override
public void beforeCreate( RunnerContext context, Point point) throws Exception
{
System.out.println("enter beforeCreate");
point.setPhoneNumber("12345");
System.out.println("exit beforeCreate");
}
}
Point.java
public class Point extends BackendLessObject {
private String phoneNumber;
public Point() {
super();
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
}
BackendlessObject.java
public class BackendLessObject {
protected String objectId;
protected Date created;
protected Date updated;
protected String ownerId;
public BackendLessObject() {
}
public String getObjectId() {
return objectId;
}
public void setObjectId( String objectId )
{
this.objectId = objectId;
}
public Date getCreated()
{
return created;
}
public void setCreated( Date created )
{
this.created = created;
}
public Date getUpdated()
{
return updated;
}
public void setUpdated( Date updated )
{
this.updated = updated;
}
public String getOwnerId() {
return ownerId;
}
#Override
public String toString() {
return objectId;
}
}
The event is enabled and deployed to production. When I run my app the point is created with all the data provided, but the PhoneNumber is not set - so the event did not run. Debugging it also shows that it was never called.
In my Android app I call
newPoint.save();

This is fixed in the latest version of the library. Make sure to grab a copy from the github repository.

Related

retrofit returning object params out of order, with # sign and quotes

I'm using retrofit to send a call to an api to post an issue in a bug-tracker through my android app. The API needs it formatted a specific way, so I created a custom object to pass as a parameter. Unfortunately when I'm sending the request to the API its formatting it incorrectly. It alphabetizes the parameters, puts quotes around both the keys and the values, and adds an # to the beginning of my data, leading the API to not be able to make sense of what I'm trying to post. The format I'm looking to send is:
{ fb_user_id: dummyUID,
email: dummy#email.com,
first_name: John,
last_name: Smith,
project: android,
type: bug,
subject: title,
description: description }
Instead of the above, my api is receiving the data as
#"description":"description",
"email":"dummy#email.com",
"fb_user_id":"dummyUID",
"first_name":"John",
"last_name":"Smith",
"project":"android",
"subject":"title",
"type":"bug"
I'm using retrofit to do so, with my interface looking like
public interface MyAPI {
#POST("/op_create_ticket")
Observable<JsonElement> createTicket(#Body Ticket ticket);
}
And my activity calling it looking like:
public class HelpActivity extends BaseActivity {
#BindView(R.id.textView)
TextView textView;
#BindView(R.id.spinner)
Spinner spinner;
#BindView(R.id.email)
EditText email;
#BindView(R.id.firstName)
EditText firstName;
#BindView(R.id.lastName)
EditText lastName;
#BindView(R.id.subject)
EditText title;
#BindView(R.id.description)
EditText description;
#BindView(R.id.button3)
Button button3;
FirebaseAuth fbauth = FirebaseAuth.getInstance();
FirebaseUser user = fbauth.getCurrentUser();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help);
ButterKnife.bind(this);
}
#OnClick(R.id.button3)
public void onViewClicked() {
final GsonBuilder gsonBuilder = new GsonBuilder();
final Gson gson = gsonBuilder.create();
Retrofit.Builder builder = new Retrofit.Builder();
builder.baseUrl("https://my.url");
builder.addCallAdapterFactory(RxJava2CallAdapterFactory.create());
builder.addConverterFactory(GsonConverterFactory.create());
Retrofit retrofit = builder.build();
MyAPI api = retrofit.create(TriggerWatchAPI.class);
Ticket ticket = new Ticket();
ticket.setFb_user_id(user.getUid());
ticket.setEmail(email.getText().toString());
ticket.setFirst_name(firstName.getText().toString());
ticket.setLast_name(lastName.getText().toString());
ticket.setProject("android");
ticket.setType("design");
ticket.setSubject(title.getText().toString());
ticket.setDescription(description.getText().toString());
api.createTicket(ticket).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<JsonElement>() {
#Override
public void onSubscribe(Disposable d) {
}
#Override
public void onNext(JsonElement jsonElement) {
Log.d(getTag(), "zzzOnNext");
}
#Override
public void onError(Throwable e) {
Log.e(getTag(), "err", e);
}
#Override
public void onComplete() {
}
});
}
}
I'm wondering if there's any kind of converter or something that can convert my object to the kind of data the API is looking for.
edit: forgot to add my custom pojo
package watch.trigger.Model;
public class Ticket {
private String project;
private String first_name;
private String email;
private String description;
private String subject;
private String last_name;
private String fb_user_id;
private String type;
public String getProject ()
{
return project;
}
public void setProject (String project)
{
this.project = project;
}
public String getFirst_name ()
{
return first_name;
}
public void setFirst_name (String first_name)
{
this.first_name = first_name;
}
public String getEmail ()
{
return email;
}
public void setEmail (String email)
{
this.email = email;
}
public String getDescription ()
{
return description;
}
public void setDescription (String description)
{
this.description = description;
}
public String getSubject ()
{
return subject;
}
public void setSubject (String subject)
{
this.subject = subject;
}
public String getLast_name ()
{
return last_name;
}
public void setLast_name (String last_name)
{
this.last_name = last_name;
}
public String getFb_user_id ()
{
return fb_user_id;
}
public void setFb_user_id (String fb_user_id)
{
this.fb_user_id = fb_user_id;
}
public String getType ()
{
return type;
}
public void setType (String type)
{
this.type = type;
}
#Override
public String toString()
{
return "ClassPojo [project = "+project+", first_name = "+first_name+", email = "+email+", description = "+description+", subject = "+subject+", last_name = "+last_name+", fb_user_id = "+fb_user_id+", type = "+type+"]";
}
}
don't send a custom object, send a JSON object as a String and in the API receive it as a JSON object.
first add this in your gradle:
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.retrofit2:converter-scalars:2.3.0'
1- change this
public interface MyAPI {
#Headers("Content-Type: application/json")
#POST("/op_create_ticket")
Observable<JsonElement> createTicket(#Body Ticket ticket);
}
to :
public interface MyAPI {
#POST("/op_create_ticket")
Observable<String> createTicket(#Body String ticket);
}
2- change this
Ticket ticket = new Ticket();
ticket.setFb_user_id(user.getUid());
ticket.setEmail(email.getText().toString());
ticket.setFirst_name(firstName.getText().toString());
ticket.setLast_name(lastName.getText().toString());
ticket.setProject("android");
ticket.setType("design");
ticket.setSubject(title.getText().toString());
ticket.setDescription(description.getText().toString());
api.createTicket(ticket).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<JsonElement>() {
#Override
public void onSubscribe(Disposable d) {
}
#Override
public void onNext(JsonElement jsonElement) {
Log.d(getTag(), "zzzOnNext");
}
#Override
public void onError(Throwable e) {
Log.e(getTag(), "err", e);
}
#Override
public void onComplete() {
}
});
to
JSONObject tickenJson= new JSONObject();
Ticket ticket = new Ticket();
ticket.setFb_user_id(user.getUid());
ticket.setEmail(email.getText().toString());
ticket.setFirst_name(firstName.getText().toString());
ticket.setLast_name(lastName.getText().toString());
ticket.setProject("android");
ticket.setType("design");
ticket.setSubject(title.getText().toString());
ticket.setDescription(description.getText().toString());
ticketJson.put("fb_user_id",user.getUid());
ticketJson.put("email",email.getText().toString());
ticketJson.put("first_name",firstName.getText().toString());
ticketJson.put("last_name",lastName.getText().toString());
ticketJson.put("project","android");
ticketJson.put("type","design");
ticketJson.put("type",title.getText().toString());
ticketJson.put("description",description.getText().toString());
api.createTicket(ticketJson.toString()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<JsonElement>() {
#Override
public void onSubscribe(Disposable d) {
}
#Override
public void onNext(JsonElement jsonElement) {
Log.d(getTag(), "zzzOnNext");
}
#Override
public void onError(Throwable e) {
Log.e(getTag(), "err", e);
}
#Override
public void onComplete() {
}
});

Correct way to update a Realm database?

This is the structure of my Realm database:
public class ARDatabase extends RealmObject
{
#PrimaryKey
private String uid;
private String namex;
private String desc;
private boolean isVideo;
private boolean isDeleted;
private String urlImg;
private String urlApp;
private int updates;
private boolean isDownloaded;
private String location;
public ARDatabase(){}
public String getUid()
{
return uid;
}
public void setUid(String uid)
{
this.uid = uid;
}
public String getNamex()
{
return namex;
}
public void setNamex(String namex)
{
this.namex = namex;
}
public String getDesc()
{
return desc;
}
public void setDesc(String desc)
{
this.desc = desc;
}
public boolean getIsVideo()
{
return isVideo;
}
public void setIsVideo(boolean isVideo)
{
this.isVideo = isVideo;
}
public boolean getIsDeleted()
{
return isDeleted;
}
public void setIsDeleted(boolean isDeleted)
{
this.isDeleted = isDeleted;
}
public String getUrlImg()
{
return urlImg;
}
public void setUrlImg(String urlImg)
{
this.urlImg = urlImg;
}
public String getUrlApp()
{
return urlApp;
}
public void setUrlApp(String urlApp)
{
this.urlApp = urlApp;
}
public int getUpdates()
{
return updates;
}
public void setUpdates(int updates)
{
this.updates = updates;
}
public boolean getIsDownloaded()
{
return isDownloaded;
}
public void setIsDownloaded(boolean isDownloaded)
{
this.isDownloaded = isDownloaded;
}
public String getLocation()
{
return location;
}
public void setLocation(String location)
{
this.location = location;
}
}
And I can successfully add objects to the database.
The problem comes when I need to update an object.
This is what I tried:
private void downloadUpdateDatabase(String uid,String location_address) throws RealmException
{
mRealm.beginTransaction();
ARDatabase db = new ARDatabase();
db.setUid(uid);
db.setIsDownloaded(true);
db.setLocation(location_address);
mRealm.copyToRealmOrUpdate(db);
mRealm.commitTransaction();
Log.e("TAG","DOWNLOAD UPDATE COMPLETED");
}
The problem here is when I invoke this method. The mentioned fields get updated, but the not mentioned fields in this method become null or zero.
Of course I can set values for all fields by invoking their setters, however from where I invoke this method, I can't get all the field values.
So, the Question is: How do I update my realm database in such a way that the existing fields don't become null ?
P.S.:
My Realm version is :0.84.1, compile 'io.realm:realm-android:0.84.1'
the field that are mentioned gets updated, however the fields that are not mentioned in this method becomes null or zero
Well, yes, all fields are their defaults at this point.
ARDatabase db = new ARDatabase();
Have you tried to query for the current record, then update the fields, then put that object back?
In other words, you have String uid, so something like
private void downloadUpdateDatabase(String uid,String location_address) throws RealmException
{
mRealm.beginTransaction();
ARDatabase db = mRealm.where(ARDatabase.class).equalTo("uid", uid).findFirst();
db.setIsDownloaded(true);
db.setLocation(location_address);
mRealm.copyToRealmOrUpdate(db);
mRealm.commitTransaction();
}
Or, probably better in async fashion.
private void downloadUpdateDatabase(final String uid, final String location_address) throws RealmException
{
mRealm.executeTransactionAsync(new Realm.Transaction() {
#Override
public void execute(Realm realm) {
ARDatabase db = realm.where(ARDatabase.class).equalTo("uid", uid).findFirst();
db.setIsDownloaded(true);
db.setLocation(location_address);
}
}, new Realm.Transaction.OnSuccess() {
#Override
public void onSuccess() {
// Transaction was a success.
}
}, new Realm.Transaction.OnError() {
#Override
public void onError(Throwable error) {
// Transaction failed and was automatically canceled.
}
});
}
Instead of
mRealm.beginTransaction();
ARDatabase db = new ARDatabase();
db.setUid(uid);
db.setIsDownloaded(true);
db.setLocation(location_address);
mRealm.copyToRealmOrUpdate(db);
mRealm.commitTransaction();
Log.e("TAG","DOWNLOAD UPDATE COMPLETED");
There should be
mRealm.executeTransaction(new Realm.Transaction() {
#Override
public void execute(Realm realm) {
ARDatabase db = realm.where(ARDatabase.class).equalTo("uid", uid).findFirst();
if(db == null) {
db = realm.createObject(ARDatabase.class, uid);
}
db.setIsDownloaded(true);
db.setLocation(location_address);
}
});
Log.e("TAG","DOWNLOAD UPDATE COMPLETED");

how to write junit test cases for Row Mapper class in spring

Hi This is my Row Mapper class.
public class UserRowMapper implements RowMapper<UserData> {
#Override
public UserData mapRow(ResultSet resultSet, int line) throws SQLException {
UserData userData = new UserData();
try
{
userData.setUserID(resultSet.getString("User_ID"));
userData.setUserName(resultSet.getString("User_Name"));
userData.setUserPassword(resultSet.getString("User_Password"));
userData.setUserRole(resultSet.getString("User_Role"));
userData.setUserStatus(resultSet.getString("User_Status"));
userData.setUserLogStatus(resultSet.getString("UserLog_Status"));
userData.setUserAccountName(resultSet.getString("User_AccountName"));
userData.setUserAccountID(resultSet.getString("User_AccountID"));
userData.setUserEmailID(resultSet.getString("User_EmailID"));
userData.setUserPasswordStatus(resultSet.getString("User_Password_ExpiryStatus"));
userData.setUserIDStatus(resultSet.getString("User_ID_Status"));
userData.setAcatTenantID(resultSet.getLong("acatTenant_ID"));
userData.setUserRoleCode(resultSet.getLong("User_Role_Code"));
userData.setUserSkillSetCode(resultSet.getLong("User_SkillSet_Code"));
userData.setUserAccountCode(resultSet.getLong("User_Account_Code"));
return userData;
}
catch (EmptyResultDataAccessException e)
{
return null;
}
}
}
and this is my Model class.
public class UserData {
private String userID;
private String userPassword;
private String userRole;
private String userStatus;
private String userLogStatus;
private String userName;
private String userAccountName;
private String userAccountID;
private String userIDStatus;
private String userPasswordStatus;
private String userEmailID;
private String userAdminID;
private String deactivationComment;
private String reqPageID;
private String userSessionID;
private String reqFunctionalityID;
private long userAccountCode;
private long userRoleCode;
private long userSkillSetCode;
private long acatTenantID;
public long getUserAccountCode() {
return userAccountCode;
}
public void setUserAccountCode(long userAccountCode) {
this.userAccountCode = userAccountCode;
}
public long getUserRoleCode() {
return userRoleCode;
}
public void setUserRoleCode(long userRoleCode) {
this.userRoleCode = userRoleCode;
}
public long getUserSkillSetCode() {
return userSkillSetCode;
}
public void setUserSkillSetCode(long userSkillSetCode) {
this.userSkillSetCode = userSkillSetCode;
}
public long getAcatTenantID() {
return acatTenantID;
}
public void setAcatTenantID(long acatTenantID) {
this.acatTenantID = acatTenantID;
}
public String getReqFunctionalityID() {
return reqFunctionalityID;
}
public void setReqFunctionalityID(String reqFunctionalityID) {
this.reqFunctionalityID = reqFunctionalityID;
}
public String getReqPageID() {
return reqPageID;
}
public void setReqPageID(String reqPageID) {
this.reqPageID = reqPageID;
}
public String getUserSessionID() {
return userSessionID;
}
public void setUserSessionID(String userSessionID) {
this.userSessionID = userSessionID;
}
public String getUserAdminID() {
return userAdminID;
}
public void setUserAdminID(String userAdminID) {
this.userAdminID = userAdminID;
}
public String getDeactivationComment() {
return deactivationComment;
}
public void setDeactivationComment(String deactivationComment) {
this.deactivationComment = deactivationComment;
}
public String getUserIDStatus() {
return userIDStatus;
}
public void setUserIDStatus(String userIDStatus) {
this.userIDStatus = userIDStatus;
}
public String getUserPasswordStatus() {
return userPasswordStatus;
}
public void setUserPasswordStatus(String userPasswordStatus) {
this.userPasswordStatus = userPasswordStatus;
}
public String getUserEmailID() {
return userEmailID;
}
public void setUserEmailID(String userEmailID) {
this.userEmailID = userEmailID;
}
public String getUserAccountID() {
return userAccountID;
}
public void setUserAccountID(String userAccountID) {
this.userAccountID = userAccountID;
}
public String getUserAccountName() {
return userAccountName;
}
public void setUserAccountName(String userAccountName) {
this.userAccountName = userAccountName;
}
public String getUserID() {
return userID;
}
public void setUserID(String userID) {
this.userID = userID;
}
public String getUserPassword() {
return userPassword;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}
public String getUserRole() {
return userRole;
}
public void setUserRole(String userRole) {
this.userRole = userRole;
}
public String getUserStatus() {
return userStatus;
}
public void setUserStatus(String userStatus) {
this.userStatus = userStatus;
}
public String getUserLogStatus() {
return userLogStatus;
}
public void setUserLogStatus(String userLogStatus) {
this.userLogStatus = userLogStatus;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
The above classes are my Row Mapper and Model class.i do not know how to write junit test class for Row Mapper class .please any one guide me how to write junit test for these classes.
Hi here is my Junit test code for above classes.
public class UserRowMapperTest {
UserRowMapper userRowMapper=null;
#Before
public void runBeforeEachTest(){
userRowMapper= new UserRowMapper();
}
#After
public void runAfterEachTest(){
userRowMapper=null;
}
#Test
public void testMapRow(){
userRowMapper.mapRow(resultSet, line);
}
}
From my point of view there is nothing to test here.
You should create unit tests only for the methods which have some business logic. I don't see the reason to test the methods which are using just getters and setters because in general they don't do anything.
However, if you want just to practice this is the advice what you could do for the unit test. First of all check some questions on how to write the unit tests because it feels like you don't understand what you need/want to achieve.
In general this is the sketch of what you want:
#Test
public void testMapRow(){
// SETUP SUT
UserRowMapper userRowMapper = new UserRowMapper()
// fill (prepare) in the Object that you want to pass to a method.
ResultSet resultSet = createResultSet();
// EXERCISE
UserData resultData = userRowMapper.mapRow(resultSet, line);
// VERIFY
Assert.assertEquals(expectedValue, resultData.getSomeValue())
}
p.s. By the way, there is no point in line parameter in this method because you don't use it.
And about the NullPointerException, please, have a look to quite popular question about it.

Realm database issue. -No default Realm Configuration was found-

This is my model class for my reminds
public class Remind extends RealmObject {
#Required
private String descripcion;
#Required
private String fecha;
#Required
private String hora;
#Required
private String titulo;
#PrimaryKey
private String id;
public Remind() {}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
public String getFecha() {
return fecha;
}
public void setFecha(String fecha) {
this.fecha = fecha;
}
public String getHora() {
return hora;
}
public void setHora(String hora) {
this.hora = hora;
}
}
this is my config class for obtain context 'cause i don't know what is the
problem with this class :(
public class RemindMe extends Application {
#RealmModule(classes = {Remind.class})
public class SimpleRealmModule {}
private static RemindMe instance;
#Override
public void onCreate() {
super.onCreate();
RealmConfiguration config = new RealmConfiguration.Builder(this).name("RemindMe.DB").build();
Realm.setDefaultConfiguration(config);
}
and this is a part of mi DAO for add some reminds
//this is so problematic class 'cause the Realm object don't find the
database context
public class RemindsDAO {
static boolean flag = false;
public boolean agregarRecordatorio(final Remind remind){
final Realm realm = Realm.getDefaultInstance();
realm.beginTransaction();
realm.executeTransaction(new Realm.Transaction() {
#Override
public void execute(Realm realm) {
Remind rem = realm.createObject(Remind.class);
rem.setId(UUID.randomUUID().toString());
rem.setTitulo(remind.getTitulo());
rem.setDescripcion(remind.getDescripcion());
rem.setHora(remind.getHora());
rem.setFecha(remind.getFecha());
}
}, new Realm.Transaction.Callback() {
#Override
public void onSuccess() {
realm.commitTransaction();
RemindsDAO.flag = true;
}
#Override
public void onError(Exception e) {
flag = false;
}
});
return flag;
}
}
You need to register your Application class in the Manifest:
<application
android:name=".RemindMe">
your activities go here...
</application>
Once done you should be able to use Realm.getDefaultInstance() throughout the app with no hassle.

Retrieve a child of a child in the Firebase Recycler View

Gettin the child "sonyTV" in the Firebase Recycler View.
the problem : this child is not a direct child of "Users"
Got the name and the date ,but not "sonyTV"
#Override
protected void onBindViewHolder(#NonNull UsersViewHolder usersViewHolder, int i, #NonNull ALL_USERS all_users) {
usersViewHolder.setName(all_users.getName());
usersViewHolder.setDate(all_users.getDate());
usersViewHolder.setUserSoldItems(all_users.getUserSoldItems());
setUserSoldItems method
public void setUserSoldItems(ALL_USERS.UserSoldItems userSoldItems) {
TextView SonyTvView = mView.findViewById(R.id.showTVsony);
SonyTvView.setText("Sony TV : "+userSoldItems);
}
ALL_USERS class
public class ALL_USERS {
private String name;
private long date;
private UserSoldItems userSoldItems;
public ALL_USERS() {}
public ALL_USERS(String name, long date, UserSoldItems userSoldItems) {
this.name = name;
this.date = date;
this.userSoldItems = userSoldItems;
}
public String getName() { return name; }
public long getDate() { return date; }
public UserSoldItems getUserSoldItems() { return userSoldItems; }
public class UserSoldItems {
private long sonyTV;
public UserSoldItems() {}
public UserSoldItems(long sonyTV) {
this.sonyTV = sonyTV;
}
public long getSonyTV() { return sonyTV; }
}
}
but it gives me null values, although you can check it in my database its not null
This is how i post to child("sonyTV")
users.child(user.getUid()).child("UserSoldItems").child("sonyTV").runTransaction(new Transaction.Handler() {
#NonNull
#Override
public Transaction.Result doTransaction(#NonNull MutableData mutableData) {
Long value = mutableData.getValue(Long.class);
if (value == null) {
mutableData.setValue(0);
}
else {
mutableData.setValue(value + 1);
}
return Transaction.success(mutableData);
}
#Override
public void onComplete(DatabaseError databaseError, boolean b,
DataSnapshot dataSnapshot) {
}
});
According to your question:
Dear Alex i have one more thing i cant get the child sonyTV in the RecyclerView ,is it beacause its not a direct child of Users node ??!!!
Now seeing what you are trying to achieve, the simplest solution I can think of is to add an extra property of type UserSoldItems in your User class. So your User class should look like this:
public class ALL_USERS {
private String name;
private long date;
private UserSoldItems userSoldItems;
public ALL_USERS() {}
public ALL_USERS(String name, long date, UserSoldItems userSoldItems) {
this.name = name;
this.date = date;
this.userSoldItems = userSoldItems;
}
public String getName() { return name; }
public long getDate() { return date; }
public UserSoldItems getUserSoldItems { return userSoldItems; }
}
And the UserSoldItems should look like this:
public UserSoldItems {
private long sonyTV;
public UserSoldItems() {}
public UserSoldItems(int sonyTV) {
this.sonyTV = sonyTV;
}
public long getSonyTV() { return sonyTV; }
}
Or even simpler:
public UserSoldItems {
public long sonyTV;
}
And please note, the name of the node should be UserSoldItems and not User Sold Items in order to make it work. So it should not contains any spaces. So when adding data, please add it without any space. In the end, just clear the actual data from the database and add fresh one.
So we introduced a new UserSoldItems level in your JSON tree, so you we can ensure that your Java classes reflect that.

Categories

Resources