我能够从表中成功检索用户名,但没有其他详细信息。
Database table name - User When i use api calls, it shows me this.
我的部分代码显示NULL错误
private void refreshItemsFromTable() {
System.out.println("[refreshItemsFromTable]");
AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>(){
@Override
protected Void doInBackground(Void... params) {
try {
final MobileServiceList<User> result =
mUserTable.select("id").execute().get();
runOnUiThread(new Runnable() {
@Override
public void run() {
for (User item : result){
System.out.println("[Querying: ]"+item);
}
}
}
});
} catch (final Exception e){
System.out.println("Exception e(1)");
}
return null;
}
};
runAsyncTask(task);
}
以下代码是我的用户类。
public class User {
@com.google.gson.annotations.SerializedName("id")
private String mId;
@com.google.gson.annotations.SerializedName("UserName")
public String mUsername;
@com.google.gson.annotations.SerializedName("UserId")
private int mUserId;
@com.google.gson.annotations.SerializedName("Password")
public String mPassword;
@com.google.gson.annotations.SerializedName("deleted")
public Boolean mDeleted;
public User() {
}
@Override
public String toString() {
return getUsername();
}
public User(String id,int mUserId,String username,String password) {
this.setId(id);
this.setUsername(username);
this.setUserId(mUserId);
this.setPassword(password);
}
public final void setId(String id){
mId = id;
}
public final void setUsername(String username) {
mUsername = username;
}
public final void setUserId(int mUserId) {
mUserId = mUserId;
}
public final void setDeleted(Boolean deleted){
mDeleted = deleted;
}
public String getUsername() {
return mUsername;
}
public String getId(){
return mId;
}
public int getUserId() {
return mUserId;
}
public Boolean getDeleted(){
return mDeleted;
}
public String getPassword() {
return mPassword;
}
public void setPassword(String mPassword) {
mPassword = mPassword;
}
@Override
public boolean equals(Object o) {
return o instanceof User && ((User) o).mId == mId;
}
}
错误日志
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.954 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.973 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.974 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.974 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.974 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.974 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.974 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.974 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.974 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.974 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.976 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.977 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.979 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.979 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.979 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.979 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.979 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.979 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.979 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.979 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.979 2150-2165/? I/System.out: [Querying: ]null
03-03 09:57:50.979 2150-2165/? I/System.out: [Querying: ]null
请帮我检测错误。感谢