0
我想從一個在線數據庫中獲取數據並根據今天顯示結果使用Textview的簡單窗體上的日期。如何從在線數據庫kinvey獲取數據
請參見下面的代碼:
myJavaClient.appData("tdSensorData", Sensor.class).get(new KinveyListCallback<Sensor>() {
@Override
public void onSuccess(Sensor[] result) {
Toast.makeText(MainActivity.this,"Get All Worked!\n Got: " + result.length,Toast.LENGTH_LONG).show();
}
@Override
public void onFailure(Throwable error) {
Toast.makeText(MainActivity.this,
"Get All error: " + error.getMessage(),
Toast.LENGTH_LONG).show();
}
});
問題是,當我試圖從實體類數據稱爲傳感器,當我從成功的方法類型result.getSensorr1()我得到一個錯誤。任何人都可以請幫助,並從土司result.length我得到4000這是正確的行數我從數據庫
這裏有我的實體類:
package com.accenture.googleglassaccenture;
import com.google.api.client.json.GenericJson;
import com.google.api.client.util.Key;
public class Sensor extends GenericJson{
@Key("_id")
private String id;
@Key("DATETIME")
private String datetime;
@Key("MAC")
private String mac;
@Key("SENSOR_1")
private String sensorr1;
@Key("SENSOR_2")
private String sensorr2;
@Key("SENSOR_3")
private String sensorr3;
@Key("SENSOR_4")
private String sensorr4;
@Key("TEMP")
private String temp;
@Key("BAT")
private String bat;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDatetime() {
return datetime;
}
public void setDatetime(String datetime) {
this.datetime = datetime;
}
public String getMac() {
return mac;
}
public void setMac(String mac) {
this.mac = mac;
}
public String getSensorr1() {
return sensorr1;
}
public void setSensorr1(String sensorr1) {
this.sensorr1 = sensorr1;
}
public String getSensorr2() {
return sensorr2;
}
public void setSensorr2(String sensorr2) {
this.sensorr2 = sensorr2;
}
public String getSensorr3() {
return sensorr3;
}
public void setSensorr3(String sensorr3) {
this.sensorr3 = sensorr3;
}
public String getSensorr4() {
return sensorr4;
}
public void setSensorr4(String sensorr4) {
this.sensorr4 = sensorr4;
}
public String getTemp() {
return temp;
}
public void setTemp(String temp) {
this.temp = temp;
}
public String getBat() {
return bat;
}
public void setBat(String bat) {
this.bat = bat;
}
public Sensor() {
// TODO Auto-generated constructor stub
}
}
這裏是結果從表看起來像
{"_id":"51a71254d06fdbee04000653","DATETIME":"2013-05-23T11:16:34Z","MAC":"0013a200407e0086","SENSOR_1":"91.19","SENSOR_2":"19.093333333333334","SENSOR_3":"439.3097042968143","SENSOR_4":"0.0","TEMP":"-17","BAT":"47","_acl":{"creator":"kid_VPuam4pfqf"},"_kmd":{"lmt":"2013-05-30T08:48:20.335Z","ect":"2013-05-30T08:48:20.335Z"}},{"_id":"51a71255d06fdbee04000654","DATETIME":"2013-05-23T11:17:33Z","MAC":"0013a200407e0086","SENSOR_1":"91.19","SENSOR_2":"19.093333333333334","SENSOR_3":"494.4776331634671","SENSOR_4":"0.0","TEMP":"-17","BAT":"47","_acl":