Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Peter Corletto
2,682 PointsInteractiveStory pages using database instead of Page[] array?
Hello All,
I don't know if I'm putting myself ahead of the course. I recently completed the Interactive Story "Signals from Mars" lesson. To store the pages of the story, you used arrays. I am thinking about expanding this app and having the ability to delete pages from the story (dynamically) and storing a much larger of pages. Is it possible to implement the story using a database instead of an array?
When I took Data Structures in college, I remember that once you create an array, it remains at the length it was created. For example, a 100-item array, even if you delete the items stored at 50 positions in the array, the 50 empty slots are still there. That causes memory overhead. I remember in that course they suggested using other data structures such as linked lists, where you can remove nodes from the list, and the memory allocated is released.
Does anyone here know if Android Studio has any kind of dynamic data structure, that allows removing records from it?
I have created apps in MIT AppInventor, and they have a component called "tinyDB" that does just that.
Thank you very much. I really appreciate any feedback.
Regards,
Peter.
2 Answers
Ben Deitch
Treehouse TeacherIs it possible to implement the story using a database instead of an array? Yep, you can find more about how to use databases in Android in this course. It's a bit more advanced than Interactive Story, but if you're curious there's no harm in giving it a shot.
Does Android Studio have any kind of dynamic data structure, that allows removing records from it? Android Studio is just the IDE we use to write our Java code, and Java has the List class which we can use for this.
Peter Corletto
2,682 PointsBen, thank you for your response! I will check out the List class.