Get data from Cloud Firestore
up vote
3
down vote
favorite

I need to get data from Firestore Firebase, I need to get the value of field "Company" from "employer" collection -> "TH17..." document. I try some things but it didnt work.
How I can do this?
I try this:
docref = db.collection("employer").document("TH17...");
docref.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document.exists()) {
String p= document.getData().toString();
Log.d("TAG", "DocumentSnapshot data: " + document.getData());
}
}
}
});
java
add a comment |
up vote
3
down vote
favorite

I need to get data from Firestore Firebase, I need to get the value of field "Company" from "employer" collection -> "TH17..." document. I try some things but it didnt work.
How I can do this?
I try this:
docref = db.collection("employer").document("TH17...");
docref.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document.exists()) {
String p= document.getData().toString();
Log.d("TAG", "DocumentSnapshot data: " + document.getData());
}
}
}
});
java
Show what you have tried. So that the answer is much more focused on the issue you are facing
– Pavan Varma
yesterday
@PavanVarma I add what i tried
– matan
yesterday
small hunch did you add <uses-permission android:name="android.permission.INTERNET" /> in Manifest
– Pavan Varma
yesterday
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite

I need to get data from Firestore Firebase, I need to get the value of field "Company" from "employer" collection -> "TH17..." document. I try some things but it didnt work.
How I can do this?
I try this:
docref = db.collection("employer").document("TH17...");
docref.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document.exists()) {
String p= document.getData().toString();
Log.d("TAG", "DocumentSnapshot data: " + document.getData());
}
}
}
});
java

I need to get data from Firestore Firebase, I need to get the value of field "Company" from "employer" collection -> "TH17..." document. I try some things but it didnt work.
How I can do this?
I try this:
docref = db.collection("employer").document("TH17...");
docref.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document.exists()) {
String p= document.getData().toString();
Log.d("TAG", "DocumentSnapshot data: " + document.getData());
}
}
}
});
java
java
edited 16 hours ago
Alex Mamo
35.3k62354
35.3k62354
asked yesterday
matan
247
247
Show what you have tried. So that the answer is much more focused on the issue you are facing
– Pavan Varma
yesterday
@PavanVarma I add what i tried
– matan
yesterday
small hunch did you add <uses-permission android:name="android.permission.INTERNET" /> in Manifest
– Pavan Varma
yesterday
add a comment |
Show what you have tried. So that the answer is much more focused on the issue you are facing
– Pavan Varma
yesterday
@PavanVarma I add what i tried
– matan
yesterday
small hunch did you add <uses-permission android:name="android.permission.INTERNET" /> in Manifest
– Pavan Varma
yesterday
Show what you have tried. So that the answer is much more focused on the issue you are facing
– Pavan Varma
yesterday
Show what you have tried. So that the answer is much more focused on the issue you are facing
– Pavan Varma
yesterday
@PavanVarma I add what i tried
– matan
yesterday
@PavanVarma I add what i tried
– matan
yesterday
small hunch did you add <uses-permission android:name="android.permission.INTERNET" /> in Manifest
– Pavan Varma
yesterday
small hunch did you add <uses-permission android:name="android.permission.INTERNET" /> in Manifest
– Pavan Varma
yesterday
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
I need to get the value of field "company" from "employer" collection -> "TH17..." document.
To solve this, please change the following lines of code:
String p= document.getData().toString();
Log.d("TAG", "DocumentSnapshot data: " + document.getData());
to
String company = document.getString("Company");
Log.d("TAG", "Company: " + company);
The result in your logcat will be:
Company: Test
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
I need to get the value of field "company" from "employer" collection -> "TH17..." document.
To solve this, please change the following lines of code:
String p= document.getData().toString();
Log.d("TAG", "DocumentSnapshot data: " + document.getData());
to
String company = document.getString("Company");
Log.d("TAG", "Company: " + company);
The result in your logcat will be:
Company: Test
add a comment |
up vote
1
down vote
accepted
I need to get the value of field "company" from "employer" collection -> "TH17..." document.
To solve this, please change the following lines of code:
String p= document.getData().toString();
Log.d("TAG", "DocumentSnapshot data: " + document.getData());
to
String company = document.getString("Company");
Log.d("TAG", "Company: " + company);
The result in your logcat will be:
Company: Test
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
I need to get the value of field "company" from "employer" collection -> "TH17..." document.
To solve this, please change the following lines of code:
String p= document.getData().toString();
Log.d("TAG", "DocumentSnapshot data: " + document.getData());
to
String company = document.getString("Company");
Log.d("TAG", "Company: " + company);
The result in your logcat will be:
Company: Test
I need to get the value of field "company" from "employer" collection -> "TH17..." document.
To solve this, please change the following lines of code:
String p= document.getData().toString();
Log.d("TAG", "DocumentSnapshot data: " + document.getData());
to
String company = document.getString("Company");
Log.d("TAG", "Company: " + company);
The result in your logcat will be:
Company: Test
edited 16 hours ago
answered 16 hours ago
Alex Mamo
35.3k62354
35.3k62354
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53230921%2fget-data-from-cloud-firestore%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Show what you have tried. So that the answer is much more focused on the issue you are facing
– Pavan Varma
yesterday
@PavanVarma I add what i tried
– matan
yesterday
small hunch did you add <uses-permission android:name="android.permission.INTERNET" /> in Manifest
– Pavan Varma
yesterday