如果TextView1已指定内容,如何将Firebase数据检索到TextView2中

时间:2018-08-30 19:33:05

标签: android firebase firebase-realtime-database

我正在研究将textbase1中的Firebase数据提取到textview2中的android应用 指定了与Firebase数据库表相关的内容

这是代码

private void FireBaseFetchedData() {

    // Receiving Data from ListView in SQLite_StockViewer Activity
    Intent intent = getIntent();
    String itemProduct = intent.getStringExtra(XlsxDB.Product);
    String ItemCode = intent.getStringExtra(XlsxDB.ItemCode);
    itemDesc.setText(itemProduct);
    itemCode.setText(ItemCode);

    mRef = FirebaseDatabase.getInstance().getReference("PricesList");
    mRef.orderByChild("item_Code").equalTo(ItemCode).addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {

            for (DataSnapshot PricesListDataSnapshot : dataSnapshot.getChildren()) {

                PricesList pricesList = PricesListDataSnapshot.getValue(PricesList.class)

                Double PublicPrice = pricesList.getPub_Price();
                Double PharmacistPrice = pricesList.getPh_Price();
                Double TaxVal = pricesList.getTax_Val();

                pubPriceHProcess.setText(String.format(PublicPrice + "%s ج.م"));
                phPriceHProcess.setText(String.format(PharmacistPrice + "%s ج.م"));
                taxHProcess.setText(String.format(TaxVal + "%s ج.م"));

            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
}

问题是没有检索到的数据 这是控制台消息

W/SyncTree: Listen at /PricesList failed: DatabaseError: Permission denied
V/FA: Inactivity, disconnecting from the service
E/ContextImpl: IllegalArgumentException unbindService: 
I/System.out: [CDS]close[46215]
I/System.out: close [socket][/0.0.0.0:46215]

PricesList是模型类

0 个答案:

没有答案