作者:婉里去_ | 来源:互联网 | 2023-05-29 15:20
WeareabletogetFirestoretodownloadrecordstothelocalcacheandcanreadthoserecords.Howe
We are able to get Firestore to download records to the local cache and can read those records. However, we are unable to update a record and not able to add a new record.
我们可以让Firestore将记录下载到本地缓存并读取这些记录。但是,我们无法更新记录,也无法添加新记录。
Have even tried some of the same code (https://github.com/firebase/quickstart-android) but don't seem to be able to get the offline write/insert working - only read.
甚至尝试了一些相同的代码(https://github.com/firebase/quickstart-android),但似乎无法让脱机写/插入工作 - 只读。
When we call this function offline it gets called OnFailureListner and throws an exception
当我们将此函数调用为脱机时,它将被调用OnFailureListner并抛出异常
@Override
public void onRating(Rating rating) {
// In a transaction, add the new rating and update the aggregate totals
addRating(mRestaurantRef, rating)
.addOnSuccessListener(this, new OnSuccessListener() {
@Override
public void onSuccess(Void aVoid) {
Log.d(TAG, "Rating added");
// Hide keyboard and scroll to top
hideKeyboard();
mRatingsRecycler.smoothScrollToPosition(0);
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "Add rating failed", e);
// Show failure message and hide keyboard
hideKeyboard();
Snackbar.make(findViewById(android.R.id.content), "Failed to add rating",
Snackbar.LENGTH_SHORT).show();
}
});
}
1 个解决方案