I'm working on book app, when the user clicks on a book on the list, my app gives the option to add that book to favorites.so the user can view the favorite books
but I don't know how to implement that..
Your question is a bit vague. I see two open questions here:
How to catch the user click and process the event?
How and where to store the book name/details?
For 1:
Just have your activity listing the books implement the corresponding event listener. See here: Android Doc - Input Events
For 2:
Depends on the amount of data you want to store if it is just a list of favorite book names Preferences might do. If you want to kep the option to extend the stored list with details fo each book then a SQLite database is your choice.
There is an Android Tutorial on how to persist data as well:
See here: Android Doc - Data Storage
And here we have a tutorial "Creating and using databases in Android".
Maintain a database for all the favourtes book. When ever user clicks on any just add that item in database and whenever requires to view the book just retrive it from the database and show it to the user so that the will be as you required.
You can store that values in 2 ways
Use Sqlite but some what coding is heavy for this.
Use serialization and deserialization to store data.
Related
I need to develop an app for university, but I don't know how to structure my data in Firebase.
In my app there are users who can create events with different questions.
Example: an event poker tournament is created with 2 questions.
1st question: Do you participate?,
2nd question: Have you ever played poker?
When the event is created, users can answer yes or no to each question. The organizer should be shown the number of yes and no answers per question.
Furthermore, the users should be able to see all the answers they have given.
I am new to Firebase and would need your help.
I use the Firestore database and program in Kotlin
Thanks
Augustin
I have set of data stored in Firebase Realtime Database (snapshot attached).
Click to View
I want to read this data when I press a button in my Android app and store it according to the person name, for example storing that Jack is 20 years old and Marry is an engineer, but I need to do this for more than just 3 users.
I'm able to call the data and read it but storing it in the way I described above is not working.
EDIT:
I added part of the code I'm working with, my main goal is when I click a button to call the data from Database, I'm able to do this but I can't figure out the best way to store this data in a way that I can use it. For example I want to display the name of the user and his role and age but I want to do this for as many users as available in database.
Code here
I recently started to learn Android and I came across a problem. I want to create a code for Firebase (the database I am using to store values) such that the contents from one set are matched to elements in another set.
The scenario is as follows: there is a student who wants to learn or is interested in learning a new skill (C/C++, drawing, music, etc.), if he were to update them in their profile, he should get suggestions as names of other users registered in the application who have already listed their skill set.
It is much like how Facebook suggests common friends, but here, the basis for suggestion is what skills the user has and what he wants to learn.
I worked on the same thing for one of my apps. I'll write about what I did to achieve that
First of all, you need to design your Realtime Database structure in a way to achieve that.
Example of a Individual User node in your database at firebase could be like
User
- Personal Details
- First name
- last name
- Dob
- Interests (values like "music,movies,sports") //Separated by a comma
- ...
Now lets say User A likes "music" and that you need to suggest him other users who likes music too, In this case what you can do is retrieve all the users who have interests "music" in their profile.
reference.addChildEventListener()
In here,inside the onChildAdded() you can compare to see if the Interest of a particular user has music in it. (if it does, add that user to your arraylist for your recyclerview to display it.)
Hope it helps!
i'm developing an android application which allows different users to login and see a list of favourite songs.
Each user has its list of songs, and a song is an instance of the corresponding class Song, with some attributes (singer, year, title...). The MainActivity contains the form for the login, so the user has to set its Name and Password. After login, a second activity is started, and it contains the ListView with the user's favourite songs.
How can i associate a single user to its corresponding song's list?
I thinked to use a database to store the songs, but then?
Look at Parse it's very easy to use and let you focus on your android App, instead of spending much time writing and configuring a server-side application.
You need also to implement on your android application a service to handle json ( or xml, it's your choice ). This is an awesome library to handle json JSONP.
Look also to this link for an overview on RESTfulservices.
For example (getting user info):
You need an info on userA.
You format a json with the right info.
Start an http request to your server. It will answer you with another json containing some info.
Parse this json recieved and use the data in your app.
I hope I made myself clear.
I'm building an app which helps in searching just like Google's search widget. In my app I have an auto-suggest which brings the typed data from wiki-suggest URL in json format. I'm able to populate it, but I want to know that how can I save my recent searches and display it on the app, just like Google's search widget do. I don't have any idea about this. Any suggestion or tweak will be helpful at this point.
Can I do one thing, typed query after pressing search button, save it simultaneously in the database or something and again if user comes back then I can populate the string in the app. Is that possible?
If yes, can some point me to how to store and retrieve string from the SQLite database.
You could use SQLite to store the search keys in a table along with a column for the time they were searched for. You could then access the most recent searches by limiting by time. A google search for SQLite Android will return a lot of resources on this issue. This tutorial might be useful to start: http://www.vogella.com/articles/AndroidSQLite/article.html.
You could use either a file you write or use SharedPreferences to store data outside off your app lifecycle: SharedPreferenes | Android Developers