以下是我的查询。
我正在尝试返回蓝色的内容,但我一直在获取红色的内容。
Query userInterestQuery = mReference
.child(mContext.getString(R.string.dbname_user_interest_post));
//.equalTo(getItem(position).getPhoto_id());
userInterestQuery.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for(DataSnapshot singleSnapshot : dataSnapshot.getChildren()){
Log.d(TAG, "onDataChange: found user this: interest " + singleSnapshot.getValue(NewPost.class).getInterest());
Log.d(TAG, "onDataChange: found user this: Caption " + singleSnapshot.getValue(NewPost.class).getCaption());
holder.interest.setText(singleSnapshot.getValue(NewPost.class).getInterest());
holder.caption.setText(singleSnapshot.getValue(NewPost.class).getInterest());
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
这是我的数据库图片
答案 0 :(得分:0)
fire-base链接添加两步:
Map<Double,Double> map=dataSnapshot.getValue(Map.class);
Double interest = map.get("interest");
System.out.println(dataSnapshot.getValue().toString());
or
System.out.println(Double.toString(interest));