Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Android Programming for Beginners

You're reading from   Android Programming for Beginners Learn all the Java and Android skills you need to start making powerful mobile applications

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher Packt
ISBN-13 9781785883262
Length 698 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
John Horton John Horton
Author Profile Icon John Horton
John Horton
 Mayani Mayani
Author Profile Icon Mayani
Mayani
Arrow right icon
View More author details
Toc

Table of Contents (37) Chapters Close

Android Programming for Beginners
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. The First App FREE CHAPTER 2. Java – First Contact 3. Exploring Android Studio 4. Designing Layouts 5. Real-World Layouts 6. The Life and Times of an Android App 7. Coding in Java Part 1 – Variables, Decisions, and Loops 8. Coding in Java Part 2 – Methods 9. Object-Oriented Programming 10. Everything's a Class 11. Widget Mania 12. Having a Dialogue with the User 13. Handling and Displaying Arrays of Data 14. Handling and Displaying Notes in Note To Self 15. Android Intent and Persistence 16. UI Animations 17. Sound FX and Supporting Different Versions of Android 18. Design Patterns, Fragments, and the Real World 19. Using Multiple Fragments 20. Paging and Swiping 21. Navigation Drawer and Where It's Snap 22. Capturing Images 23. Using SQLite Databases in Our Apps 24. Adding a Database to Where It's Snap 25. Integrating Google Maps and GPS Locations 26. Upgrading SQLite – Adding Locations and Maps 27. Going Local – Hola! 28. Threads, Touches, Drawing, and a Simple Game 29. Publishing Apps 30. Before You Go Index

Handling large amount of data with arrays


You might be wondering what happens when we have an app with lots of variables that we need to keep track of. What about our Note To Self app with 100 notes or a high score table in a game with the top 100 scores? We could declare and initialize 100 separate variables, like so:

Note note1;
Note note2;
Note note3;
//96 more lines like the above
Note note100;

Or, we could begin to handle the high scores scenario like this:

int topScore1;
int topScore2;
int topScore3;
//96 more lines like the above
int topScore100;

Straight away, this can seem unwieldy, but what about when someone gets a new top score or we want to let our users sort the order their notes are displayed in? Using the high scores scenario, we have to shift the scores in every variable down one place. A nightmare begins. We could handle the high scores as follows:

topScore100 = topScore99;
topScore99 = topScore98;
topScore98 = topScore97;
//96 more lines like the above
topScore1 = score;

There...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images