我正在尝试从firebase数据库中获取数据。我正在使用FirebaseDatabase。在获取数据的同时,我获得了异常。在firebase和local中没有长变量。我得到了正确的数据。
DatabaseReference firebase = Firebase.getInstance().getReference().child(FirebaseConfig.PRODUCT_MASTER);
Query query = firebase.orderByChild(getString(R.string.COLUMN_RETAILER_ID)).equalTo(retailerId);
query.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Product_Master productMaster = dataSnapshot.getValue(Product_Master.class);
pdtMasterList.add(productMaster);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot,
String s){
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
public class Product_Master {
@SerializedName("brand")
private String brand;
@SerializedName("category")
private String category;
@SerializedName("display_name")
private String display_name;
@SerializedName("dealer_price")
private String dealer_price;
@SerializedName("distributor_id")
private String distributor_id;
@SerializedName("EAN")
private String EAN;
@SerializedName("image")
private String image;
@SerializedName("image_folder")
private String image_folder;
@SerializedName("item_description1")
private String item_description1;
@SerializedName("item_description2")
private String item_description2;
@SerializedName("item_id")
private String item_id;
@SerializedName("loose_category")
private String loose_category;
@SerializedName("description")
private String description;
@SerializedName("major_category")
private String major_category;
@SerializedName("moq")
private String moq;
@SerializedName("sub_category")
private String sub_category;
@SerializedName("varaiety")
private String varaiety;
@SerializedName("vat_percent")
private String vat_percent;
@SerializedName("type_product")
private String type_product;
@SerializedName("weight")
private String weight;
@SerializedName("offer_price")
private String offer_price;
@SerializedName("offer_indicator")
private String offer_indicator;
@SerializedName("mov")
private String mov;
@SerializedName("retailer_id")
private String retailer_id;
@SerializedName("retailer_price")
private String retailer_price;
@SerializedName("market_price")
private String market_price;
@SerializedName("price")
private ArrayList<Price> price;
public String getMov() {
return mov;
}
public void setMov(String mov) {
this.mov = mov;
}
public String getRetailer_price() {
return retailer_price;
}
public void setRetailer_price(String retailer_price) {
this.retailer_price = retailer_price;
}
public String getOffer_price() {
return offer_price;
}
public void setOffer_price(String offer_price) {
this.offer_price = offer_price;
}
public String getOffer_indicator() {
return offer_indicator;
}
public void setOffer_indicator(String offer_indicator) {
this.offer_indicator = offer_indicator;
}
public Product_Master() {
}
public String getDealer_price() {
return dealer_price;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public String getImage_folder() {
return image_folder;
}
public void setImage_folder(String image_folder) {
this.image_folder = image_folder;
}
public void setDealer_price(String dealer_price) {
this.dealer_price = dealer_price;
}
public String getDisplay_name() {
return display_name;
}
public void setDisplay_name(String display_name) {
this.display_name = display_name;
}
public String getDistributor_id() {
return distributor_id;
}
public void setDistributor_id(String distributor_id) {
this.distributor_id = distributor_id;
}
public String getMoq() {
return moq;
}
public void setMoq(String moq) {
this.moq = moq;
}
public String getRetailer_id() {
return retailer_id;
}
public String getMarket_price() {
return market_price;
}
public void setMarket_price(String market_price) {
this.market_price = market_price;
}
public void setRetailer_id(String retailer_id) {
this.retailer_id = retailer_id;
}
public String getItem_id() {
return item_id;
}
public void setItem_id(String item_id) {
this.item_id = item_id;
}
public String getItem_description1() {
return item_description1;
}
public void setItem_description1(String item_description1) {
this.item_description1 = item_description1;
}
public String getItem_description2() {
return item_description2;
}
public void setItem_description2(String item_description2) {
this.item_description2 = item_description2;
}
public String getMajor_category() {
return major_category;
}
public void setMajor_category(String major_category) {
this.major_category = major_category;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getSub_category() {
return sub_category;
}
public void setSub_category(String sub_category) {
this.sub_category = sub_category;
}
public String getVaraiety() {
return varaiety;
}
public void setVaraiety(String varaiety) {
this.varaiety = varaiety;
}
public String getLoose_category() {
return loose_category;
}
public void setLoose_category(String loose_category) {
this.loose_category = loose_category;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getEAN() {
return EAN;
}
public void setEAN(String EAN) {
this.EAN = EAN;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getWeight() {
return weight;
}
public void setWeight(String weight) {
this.weight = weight;
}
public String getVat_percent() {
return vat_percent;
}
public void setVat_percent(String vat_percent) {
this.vat_percent = vat_percent;
}
public String getType_product() {
return type_product;
}
public void setType_product(String type_product) {
this.type_product = type_product;
}
public ArrayList<Price> getPrice() {
return price;
}
public void setPrice(ArrayList<Price> price) {
this.price = price;
}
public static class Price
{
private String weight;
private String offer_price;
private String dealer_price;
public Price(String weight, String offer_price, String dealer_price) {
this.weight = weight;
this.offer_price = offer_price;
this.dealer_price = dealer_price;
}
public String getWeight() {
return weight;
}
public void setWeight(String weight) {
this.weight = weight;
}
public String getOffer_price() {
return offer_price;
}
public void setOffer_price(String offer_price) {
this.offer_price = offer_price;
}
public String getDealer_price() {
return dealer_price;
}
public void setDealer_price(String dealer_price) {
this.dealer_price = dealer_price;
}
}
}
{
"brand" : "GTS Bullet",
"category" : "RICE",
"dealer_price" : "1000",
"description" : "Sona Masuri - A1 Quality - 25Kg",
"display_name" : "SuperZop Traders",
"distributor_id" : "1001",
"ean" : "",
"image" : "sona_masuri_rice_large.jpg",
"image_folder" : "superzop_ordering_product_images",
"item_description1" : "Sona Masuri",
"item_description2" : "A1 Quality",
"item_id" : "100001",
"loose_category" : "RICE",
"major_category" : "GROCERY",
"market_price" : "",
"moq" : "50Kg",
"mov" : "5000",
"offer_indicator" : "",
"offer_price" : "800",
"retailer_id" : 10001,
"sub_category" : "RICE",
"type_product" : "MRP",
"varaiety" : "",
"vat_percent" : "12.50%",
"weight" : "25Kg"
}