我正在开发Android应用,并且我使用Firebase作为数据库。 我希望得到一个特定的节点,但我没有检索到这些数据。
我已经编写了Firebase的安全规则,这是我的数据结构:
这是我的Android代码:
filtered_data = filter(b,a,plotData);
这是位置类
public void connect() {
//setting connexion parameter
final Firebase ref = new Firebase("https://test.firebaseio.com/test");
Query query = ref.orderByChild("longitude").equalTo("150");
//get the data from th DB
query.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//checking if the user exist
if(dataSnapshot.exists())
for (DataSnapshot userSnapshot : dataSnapshot.getChildren()) {
//get each user which has the target username
final Location location = userSnapshot.getValue(Location.class);
//if the password is true , the data will be storaged in the sharedPreferences file and a Home activity will be launched
System.out.println("hello map"+location.getLongitude());
}
System.out.println("not found");
}
@Override
public void onCancelled(FirebaseError firebaseError) {
System.out.println("problem ");
}
});
}
}