how to get value from a text file and link with firebase
up vote
0
down vote
favorite
I have a text file containing userPhone and the relevant foodId for recommendation purposes in a menu app.
I have successfully read the relevant foodId based on each userPhone login. How am I able to get the foodId from the text file and retrieve from firebase to display in recycler view? foodId are stored in firebase.
(different user login will display the relevant foodId based on each phone number). I am just a beginner. Thanks in advance
.txt file
0122233444=47
0125547890=48
9876543210=54,29,49
Recommendation.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recommendation);
TextView recList = (TextView)findViewById(R.id.rec_list);
//Firebase
database = FirebaseDatabase.getInstance();
String userPhone = Common.currentUser.getPhone();
String recommend = findRecommendation(userPhone);
if (recommend != null) {
recList.setText(recommend);
} else {
recList.setText("Not enough transaction");
}
}
private String findRecommendation(String userPhone) {
//open raw resource and connect to input stream variable
InputStream input = getResources().openRawResource(R.raw.foodrecommendation);
//scanner
Scanner scan = new Scanner(input);
while (scan.hasNext()) {
String line = scan.nextLine(); //phoneNo + foodId
String pieces = line.split("=");
if (pieces[0].equalsIgnoreCase(userPhone.trim())) {
return pieces[1];
}
}
return null;
}
Firebase structure
foodId
user phone number
java android firebase firebase-realtime-database
|
show 5 more comments
up vote
0
down vote
favorite
I have a text file containing userPhone and the relevant foodId for recommendation purposes in a menu app.
I have successfully read the relevant foodId based on each userPhone login. How am I able to get the foodId from the text file and retrieve from firebase to display in recycler view? foodId are stored in firebase.
(different user login will display the relevant foodId based on each phone number). I am just a beginner. Thanks in advance
.txt file
0122233444=47
0125547890=48
9876543210=54,29,49
Recommendation.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recommendation);
TextView recList = (TextView)findViewById(R.id.rec_list);
//Firebase
database = FirebaseDatabase.getInstance();
String userPhone = Common.currentUser.getPhone();
String recommend = findRecommendation(userPhone);
if (recommend != null) {
recList.setText(recommend);
} else {
recList.setText("Not enough transaction");
}
}
private String findRecommendation(String userPhone) {
//open raw resource and connect to input stream variable
InputStream input = getResources().openRawResource(R.raw.foodrecommendation);
//scanner
Scanner scan = new Scanner(input);
while (scan.hasNext()) {
String line = scan.nextLine(); //phoneNo + foodId
String pieces = line.split("=");
if (pieces[0].equalsIgnoreCase(userPhone.trim())) {
return pieces[1];
}
}
return null;
}
Firebase structure
foodId
user phone number
java android firebase firebase-realtime-database
Please be more precise to what you're saying, it's a bit unclear, If you could take an example to tell, it would be better for people to understand.
– PradyumanDixit
Nov 21 at 14:07
why are you keeping phone numbers in a file like that it will unnecessary increase the app size. better you keep eveything in firevase database and get the recommended data for the user
– Har Kal
Nov 21 at 22:51
@PradyumanDixit im storing relevant foodId based on each userPhone which is for recommendation purposes. When the user login based on their phoneNumbers, the app will only recommend the food found in the textfile based on the userPhone. All foodId are stored in firebase. However, i do not know how to display the only foodId in the text file where can be retrieved from firebase.
– Blue77
Nov 22 at 6:26
@HarKal i do not know how to store only specific foodId based on each userPhone. Because i already have all foodId in my firebase. So i save in a textfile and read each foodId based on each user login for recommendation purposes in a restaurant menu.
– Blue77
Nov 22 at 6:29
i have successfully read each relevant foodId based on each user login. But i want to get the foodId by retrieving it from firebase and display in recycler view. Thanks
– Blue77
Nov 22 at 6:31
|
show 5 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a text file containing userPhone and the relevant foodId for recommendation purposes in a menu app.
I have successfully read the relevant foodId based on each userPhone login. How am I able to get the foodId from the text file and retrieve from firebase to display in recycler view? foodId are stored in firebase.
(different user login will display the relevant foodId based on each phone number). I am just a beginner. Thanks in advance
.txt file
0122233444=47
0125547890=48
9876543210=54,29,49
Recommendation.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recommendation);
TextView recList = (TextView)findViewById(R.id.rec_list);
//Firebase
database = FirebaseDatabase.getInstance();
String userPhone = Common.currentUser.getPhone();
String recommend = findRecommendation(userPhone);
if (recommend != null) {
recList.setText(recommend);
} else {
recList.setText("Not enough transaction");
}
}
private String findRecommendation(String userPhone) {
//open raw resource and connect to input stream variable
InputStream input = getResources().openRawResource(R.raw.foodrecommendation);
//scanner
Scanner scan = new Scanner(input);
while (scan.hasNext()) {
String line = scan.nextLine(); //phoneNo + foodId
String pieces = line.split("=");
if (pieces[0].equalsIgnoreCase(userPhone.trim())) {
return pieces[1];
}
}
return null;
}
Firebase structure
foodId
user phone number
java android firebase firebase-realtime-database
I have a text file containing userPhone and the relevant foodId for recommendation purposes in a menu app.
I have successfully read the relevant foodId based on each userPhone login. How am I able to get the foodId from the text file and retrieve from firebase to display in recycler view? foodId are stored in firebase.
(different user login will display the relevant foodId based on each phone number). I am just a beginner. Thanks in advance
.txt file
0122233444=47
0125547890=48
9876543210=54,29,49
Recommendation.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recommendation);
TextView recList = (TextView)findViewById(R.id.rec_list);
//Firebase
database = FirebaseDatabase.getInstance();
String userPhone = Common.currentUser.getPhone();
String recommend = findRecommendation(userPhone);
if (recommend != null) {
recList.setText(recommend);
} else {
recList.setText("Not enough transaction");
}
}
private String findRecommendation(String userPhone) {
//open raw resource and connect to input stream variable
InputStream input = getResources().openRawResource(R.raw.foodrecommendation);
//scanner
Scanner scan = new Scanner(input);
while (scan.hasNext()) {
String line = scan.nextLine(); //phoneNo + foodId
String pieces = line.split("=");
if (pieces[0].equalsIgnoreCase(userPhone.trim())) {
return pieces[1];
}
}
return null;
}
Firebase structure
foodId
user phone number
java android firebase firebase-realtime-database
java android firebase firebase-realtime-database
edited Nov 22 at 7:29
asked Nov 21 at 13:16
Blue77
22
22
Please be more precise to what you're saying, it's a bit unclear, If you could take an example to tell, it would be better for people to understand.
– PradyumanDixit
Nov 21 at 14:07
why are you keeping phone numbers in a file like that it will unnecessary increase the app size. better you keep eveything in firevase database and get the recommended data for the user
– Har Kal
Nov 21 at 22:51
@PradyumanDixit im storing relevant foodId based on each userPhone which is for recommendation purposes. When the user login based on their phoneNumbers, the app will only recommend the food found in the textfile based on the userPhone. All foodId are stored in firebase. However, i do not know how to display the only foodId in the text file where can be retrieved from firebase.
– Blue77
Nov 22 at 6:26
@HarKal i do not know how to store only specific foodId based on each userPhone. Because i already have all foodId in my firebase. So i save in a textfile and read each foodId based on each user login for recommendation purposes in a restaurant menu.
– Blue77
Nov 22 at 6:29
i have successfully read each relevant foodId based on each user login. But i want to get the foodId by retrieving it from firebase and display in recycler view. Thanks
– Blue77
Nov 22 at 6:31
|
show 5 more comments
Please be more precise to what you're saying, it's a bit unclear, If you could take an example to tell, it would be better for people to understand.
– PradyumanDixit
Nov 21 at 14:07
why are you keeping phone numbers in a file like that it will unnecessary increase the app size. better you keep eveything in firevase database and get the recommended data for the user
– Har Kal
Nov 21 at 22:51
@PradyumanDixit im storing relevant foodId based on each userPhone which is for recommendation purposes. When the user login based on their phoneNumbers, the app will only recommend the food found in the textfile based on the userPhone. All foodId are stored in firebase. However, i do not know how to display the only foodId in the text file where can be retrieved from firebase.
– Blue77
Nov 22 at 6:26
@HarKal i do not know how to store only specific foodId based on each userPhone. Because i already have all foodId in my firebase. So i save in a textfile and read each foodId based on each user login for recommendation purposes in a restaurant menu.
– Blue77
Nov 22 at 6:29
i have successfully read each relevant foodId based on each user login. But i want to get the foodId by retrieving it from firebase and display in recycler view. Thanks
– Blue77
Nov 22 at 6:31
Please be more precise to what you're saying, it's a bit unclear, If you could take an example to tell, it would be better for people to understand.
– PradyumanDixit
Nov 21 at 14:07
Please be more precise to what you're saying, it's a bit unclear, If you could take an example to tell, it would be better for people to understand.
– PradyumanDixit
Nov 21 at 14:07
why are you keeping phone numbers in a file like that it will unnecessary increase the app size. better you keep eveything in firevase database and get the recommended data for the user
– Har Kal
Nov 21 at 22:51
why are you keeping phone numbers in a file like that it will unnecessary increase the app size. better you keep eveything in firevase database and get the recommended data for the user
– Har Kal
Nov 21 at 22:51
@PradyumanDixit im storing relevant foodId based on each userPhone which is for recommendation purposes. When the user login based on their phoneNumbers, the app will only recommend the food found in the textfile based on the userPhone. All foodId are stored in firebase. However, i do not know how to display the only foodId in the text file where can be retrieved from firebase.
– Blue77
Nov 22 at 6:26
@PradyumanDixit im storing relevant foodId based on each userPhone which is for recommendation purposes. When the user login based on their phoneNumbers, the app will only recommend the food found in the textfile based on the userPhone. All foodId are stored in firebase. However, i do not know how to display the only foodId in the text file where can be retrieved from firebase.
– Blue77
Nov 22 at 6:26
@HarKal i do not know how to store only specific foodId based on each userPhone. Because i already have all foodId in my firebase. So i save in a textfile and read each foodId based on each user login for recommendation purposes in a restaurant menu.
– Blue77
Nov 22 at 6:29
@HarKal i do not know how to store only specific foodId based on each userPhone. Because i already have all foodId in my firebase. So i save in a textfile and read each foodId based on each user login for recommendation purposes in a restaurant menu.
– Blue77
Nov 22 at 6:29
i have successfully read each relevant foodId based on each user login. But i want to get the foodId by retrieving it from firebase and display in recycler view. Thanks
– Blue77
Nov 22 at 6:31
i have successfully read each relevant foodId based on each user login. But i want to get the foodId by retrieving it from firebase and display in recycler view. Thanks
– Blue77
Nov 22 at 6:31
|
show 5 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412918%2fhow-to-get-value-from-a-text-file-and-link-with-firebase%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please be more precise to what you're saying, it's a bit unclear, If you could take an example to tell, it would be better for people to understand.
– PradyumanDixit
Nov 21 at 14:07
why are you keeping phone numbers in a file like that it will unnecessary increase the app size. better you keep eveything in firevase database and get the recommended data for the user
– Har Kal
Nov 21 at 22:51
@PradyumanDixit im storing relevant foodId based on each userPhone which is for recommendation purposes. When the user login based on their phoneNumbers, the app will only recommend the food found in the textfile based on the userPhone. All foodId are stored in firebase. However, i do not know how to display the only foodId in the text file where can be retrieved from firebase.
– Blue77
Nov 22 at 6:26
@HarKal i do not know how to store only specific foodId based on each userPhone. Because i already have all foodId in my firebase. So i save in a textfile and read each foodId based on each user login for recommendation purposes in a restaurant menu.
– Blue77
Nov 22 at 6:29
i have successfully read each relevant foodId based on each user login. But i want to get the foodId by retrieving it from firebase and display in recycler view. Thanks
– Blue77
Nov 22 at 6:31