how to get value from a text file and link with firebase
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
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 '18 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 '18 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 '18 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 '18 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 '18 at 6:31
|
show 5 more comments
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 '18 at 7:29
Blue77
asked Nov 21 '18 at 13:16
Blue77Blue77
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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 6:31
|
show 5 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
0
active
oldest
votes
0
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.
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 '18 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 '18 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 '18 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 '18 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 '18 at 6:31