There is an issue in my app that connect to firebase real time database ..
when i try to insert data to firebase during offline... when internet available the data automaticaly send to firebase database.. when my app close on offline then the insert will not happen...
i want to prevent the data insert to firebase which the after effect of insert try during offline...
//------------------------------------------------
private void onStarClicked(final DatabaseReference postRef) {
postRef.runTransaction(new Transaction.Handler() {
@Override
public Transaction.Result doTransaction(MutableData mutableData) {
if (mutableData.hasChildren()) {
int inv = 0;
for (MutableData postData : mutableData.getChildren()) {
inv = postData.child("inv").getValue(Integer.class);
}
SalesModel salesModel = new SalesModel("samsung",inv+1,987.90);
String newKey = postRef.push().getKey();
// Set value and report transaction success
mutableData.child(newKey).setValue(salesModel);
}
// Set value and report transaction success
// mutableData.setValue(p);
return Transaction.success(mutableData);
}
@Override
public void onComplete(DatabaseError databaseError, boolean b,
DataSnapshot dataSnapshot) {
// Transaction completed
// Log.d(TAG, "postTransaction:onComplete:" + databaseError);
}
});
}
//------------------------------------------------------/