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










share|improve this question
























  • 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















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










share|improve this question
























  • 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













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










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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

















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',
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
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Berounka

Sphinx de Gizeh

Different font size/position of beamer's navigation symbols template's content depending on regular/plain...