Created
May 9, 2018 14:42
-
-
Save griajobag/cfbf53d812bcadb708e536748c71522c to your computer and use it in GitHub Desktop.
firestore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void startInsertDataDocumentManual() { | |
progressDialog.show(); | |
for (int i = 0; i < 5; i++) { | |
Map<String, Object> data = new HashMap<>(); | |
data.put("nama", "putuguna " + i); | |
data.put("website", "putuguna.com " + i); | |
data.put("temaWeb", "Tentang Programming " +i); | |
CollectionReference collectionReference = firebaseFirestore.collection("data"); | |
DocumentReference documentReference = collectionReference.document("document"+i); | |
documentReference.set(data) | |
.addOnSuccessListener(new OnSuccessListener<Void>() { | |
@Override | |
public void onSuccess(Void aVoid) { | |
progressDialog.dismiss(); | |
Toast.makeText(MainActivity.this, "Berhasil Insert Data", Toast.LENGTH_SHORT).show(); | |
} | |
}) | |
.addOnFailureListener(new OnFailureListener() { | |
@Override | |
public void onFailure(@NonNull Exception e) { | |
progressDialog.dismiss(); | |
Toast.makeText(MainActivity.this, "Gagal Insert Data", Toast.LENGTH_SHORT).show(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment