火力孩子在android的存在与否 [英] firebase child exists or not in android

查看:190
本文介绍了火力孩子在android的存在与否的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是相似的张贴问题<一href=\"http://stackoverflow.com/questions/11420650/proper-use-of-haschild-and-foreach-from-a-reference-in-firebase\">here

My question is similar to the question posted here


  1. 我呼吁用户表火力地堡路径,比如应用程序的名字/用户

  2. 我想看看用户是否存在。

  3. 我得到一个参考:火力地堡用户=
    ref.child('用户');

我想知道是否有一个等价的Java code相似,提供的JavaScript答案。我问这个,因为我是用火力地堡的客户端的最新版本,我无法找到方法一次(),它被称为,看是否有孩子存在与否。

I am wondering if there is an equivalent Java code similar to javascript answer provided. I ask this because in the latest version of Firebase-client that I am using I am unable to find the method once(), which has been called to see if a child exists or not.

编辑1:

我是用发展的Eclipse IDE和我在网页中指定的位置下载火力罐子。我无法用几个方法,我没有看到任何人被指定。

I am using the eclipse IDE for development and I have download the firebase jar from the location specified in the web page. I am unable to use a couple of methods as I do not see any of them being specified.

Firebase ref = new Firebase(url);
Firebase usersRef = ref.child("users");

当我尝试一次,使用的方法()/ hasChild()的IDE不显示任何这些方法是可用的。我不知道这是否只是我结束或者如果我需要下载并使用另一个罐子?

When I try to use the method once()/ hasChild() the IDE does not show any of these methods being available. I am not sure if it is only at my end or if I need to download and use another jar?

任何建议吗?

推荐答案

我想你要找的是什么<一个href=\"https://www.firebase.com/docs/java-api/javadoc/com/firebase/client/Query.html#addListenerForSingleValueEvent%28com.firebase.client.ValueEventListener%29\"相对=nofollow> addListenerForSingleValueEvent 。它是Java相当于JavaScript中的'一次'功能。此外,hasChild'方法可在的 DataSnapshot 类,它将在回调提供给你的听众。一般情况下,你可以找到本文所述的所有的Java API:的https:/ /www.firebase.com/docs/java-api/javadoc/index.html

I think what you're looking for is addListenerForSingleValueEvent. It is the Java equivalent to the 'once' function in javascript. In addition, the 'hasChild' method is available on the DataSnapshot class, which will be provided in the callback to your listener. In general, you can find all of the Java API documented here: https://www.firebase.com/docs/java-api/javadoc/index.html

这篇关于火力孩子在android的存在与否的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆