Skip to content

Instantly share code, notes, and snippets.

@griajobag
Created May 16, 2018 15:39
Show Gist options
  • Save griajobag/3f751b72408445214d11c6f08e4c186c to your computer and use it in GitHub Desktop.
Save griajobag/3f751b72408445214d11c6f08e4c186c to your computer and use it in GitHub Desktop.
firestores
private void updateTheData() {
progressDialog.setMessage("Updating Data...");
progressDialog.show();
WebsiteModel model = new WebsiteModel("Droid Newbie (updated)", "androidbie.com (updated)", "About Programming (updated)", modelWebsite.get(0).getIdDocument());
CollectionReference collectionReference = firebaseFirestore.collection("data");
DocumentReference documentReference = collectionReference.document(modelWebsite.get(0).getIdDocument());
documentReference.set(model)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
progressDialog.dismiss();
Toast.makeText(MainActivity.this, "Updating successfully", Toast.LENGTH_SHORT).show();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
progressDialog.dismiss();
Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment