Reputation: 177
Hi I am fairly new to Android development and am hoping someone can help me out with this.
Basically, the app I am designing needs to contain a large list of makes, models, and years for various cars. The user can then select the make/model/year they want and add this car to their personal list of favorites. What I have tried so far is to make a database with two tables: one listing every car, and one listing the cars the user has chosen as favorites. When a user selects a car from the table listing every car, ideally that data would just be copied to the second table.
This has been fairly difficult for me at my novice level and I am having some problems getting it to work at all. So i guess my question is: is there a simpler way I should do this (with multiple arrays or something)? Or should I man up and just keep going at it until it works?
Upvotes: 1
Views: 217
Reputation: 13
I would suggest you to stick with the database because having arrays and hardcoding it will make your program bigger and needs more memory (even in RAM) which is limited in cell phones.
To get you thing done, I would suggest you to use flags as the folks have said plus, to ease your programming, use a dbHelper and make a function for copying data from one table to another, I think that is fairly simple.
Upvotes: 0
Reputation: 1883
You have to make two tables CarlistTable & favouriteTable . Add a Column favorite to carlist & make each entry 0 to this column & while mark it as favourite do two things 1.Update the perticular entry as 1 & save that entry to Favourite Table. Thats all.
Upvotes: 0
Reputation: 2126
I would stick with the database - it will serve you well for more advanced android development, and many other applications. Sounds like you need to get a book on SQL or fundamental database concepts - if the database is as you've described it you can just use one table and update the "Favourite" flag whenever that changes.
Using alternative structures can have it's own learning curve and be at the cost of performance, particularly if you've got a large number of records. Is there anything specifically you're stuck on?
Upvotes: 1