我还在试图了解firebase时间戳的工作原理。我发现,当在firebase中更新时间戳值时,该值会像计时器或秒表一样不停地更新,导致应用程序冻结,还是说,时间值一旦保存,就不能在应用程序中用新的值替换?
我是这样尝试在我的应用程序中更新时间的
mRootRef.child("Chat").child(mOtherUser).child(mCurrentUserId).child("timestamp").setValue(ServerValue.TIMESTAMP);
我需要在我的应用程序中为数据库中的项目随后更新时间戳值,因为它们在我的应用程序中就是这样排序的。
postsMap.put("timestamp", GlobalVarables.timeStamp);
@Override
protected void onStart() {
super.onStart();
GlobalVarables.timeStamp= String.valueOf(System.currentTimeMillis());
}
这是我如何固定我的我删除 ServerValue.Timestamp
并代之以 System.currentTimeMillis()
然后创建了 GlobalVarables
类来保持该值,然后在映射过程中调用它。