Last active
December 5, 2020 07:03
-
-
Save ns-github14/15d6962ea7d890164f72a888aa4bdfc1 to your computer and use it in GitHub Desktop.
This file contains 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
public class Test extends AppCompatActivity { | |
private FirebaseFirestore yourDB; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_test); | |
yourDB = FirebaseFirestore.getInstance(); | |
} | |
@Override | |
public void onStart(){ | |
super.onStart(); | |
yourDB.collection("Doctors").document("abc@xyz.com").get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() { | |
@Override | |
public void onComplete(@NonNull Task<DocumentSnapshot> task) { | |
if(task.isSuccessful()){ | |
DocumentSnapshot doc = task.getResult(); | |
//set name next to Name TextView | |
(editText1.setText(doc.getString("Name")); | |
//set email next to Email TextView | |
(editText2.setText(doc.getString("Email")); | |
//convert contact field from number to String | |
//set contact next to Contact TextView | |
(editText3.setText(doc.getLong("Contact").toString()); | |
//similarly get all the other fields} | |
} | |
}) | |
.addOnFailureListener(new OnFailureListener() { | |
@Override | |
public void onFailure(@NonNull Exception e) { | |
//print e.message(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment