• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

how to display the highest score in a game

Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am creating a game called Jumbled Words in which the user is given a word in a scrambled format for which the user has to unscramble it. For each correct answer the score gets incremented by 10 and the user is shown the current score. After the user exits the application the current score should get stored somewhere, say a file or a database (assuming the game is played for the first time) and display it as the highest score. Suppose for the first time the game is played and the score is 100 and the value is stored in the file/DB, for the second time when the user plays the game and the score is 200. By assuming 200 is the highest score compared to the highest score in the file or DB i.e. 100, the value 100 must be replaced by 200 and display 200 as highest score. Whenever the user wants to see the highest score, it should retrieve the highest score and display it in a view.

I want the following suggestions from my folks:

1. What type of data storage system must I use? A file, database or a properties file. Which would be better.

2. What logic must I apply to display the highest score?

3. What APIs of Android must I use for the File, DB or Properties?javascript:emoticon('');
Posts: 5856
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Since you only have some very simple data, store it in Shared Preferences or as a property file in Internal Storage (see point #3)

2) I recommend that you compare the current score to the prior high score, and if the current score is higher, then store the current score as the highest score. Your displayHighScore() method should then always read the score from storage.

3) See http://developer.android.com/guide/topics/data/data-storage.html
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how it can be generated?
F is for finger. Can you stick your finger in your nose? Doesn't that feel nice? Now try this tiny ad:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic