1. Are you ready for the Galaxy S20? Here is everything we know so far!

Help for a rusty coder

Discussion in 'Android Development' started by Force39, Apr 20, 2012.

  1. Force39

    Force39 Lurker
    Thread Starter

    Hi everyone.

    I'm after a little help to get me started on an app I'm writing. I've done some Java and c# coding in the past but I've not done much for a good number of years. Apologies, therefore, if I get some of my terms wrong!

    I'm writing an app that only I will use, so I suspect there's a lot of stuff I won't need to worry about.

    I've got the bare bones of the app working (a couple of different screens and some very basic functions). However I've got a bit stuck on the next part, so it's time to ask for help!

    I want to do the following:
    1. Deploy several text files to the SD card as part of installing the app. (This is to allow me to overwrite the files once I start using the app, my way of doing some updates).

    2. On one screen, choose one of the files and load the contents into an array (or something array-like, I'm aware there might be better constructs to use).

    3. On various other screens, access the contents of that array.

    Currently I've got the following classes:
    - HelloAndroid.java class (yes, it's still called that!) which contains the OnCreate and a copule of on-click methods.
    - Global.java, extends Application which contains some Static variables so I can access them in the various on-click methods.

    Like I say, my Java is really rusty and I've hit a bit of a dead end on what feels like it should be a fairly simple task.

    I'm using Eclipse, and I'd really appreciate any help that anyone could give. Ideally in fairly basic terms!
     



    1. Download the Forums for Android™ app!


      Download

       
  2. jonbonazza

    jonbonazza Android Expert

    Hello,

    1) There is no way to do anything when the app is installed. The best you can do is check the data on the sd card, and handle it appropriately. For this, you will obviously need some kind of persistent data store, such as SharedPreferences, but the exact implementation depends entirely on your app's needs.

    2) In this case, I would used a LinkedList object instead of an array. It's easier to implement as you don't need to know the size of the list ahead of time. The way you load it would depend on the file structure and whether it was binary or plain-text. More info is needed to give a better answer.

    3) What do you wish to do with the data once accessed?
     
  3. Force39

    Force39 Lurker
    Thread Starter

    I can live with that, I'll have a look into SharedPreferences

    The file structure is up to me, it's likely to be either csv or XML. Basically I'm loading information on sports players (Squad Number, Surname). Each team will have their own text file containing all their players.

    The plan is to load the list of players from the text file (see point 2) and then have a screen allowing you to select which player has just scored. From that, it's going to put start building up a string to send vie Twitter or SMS to send score updates.

    So the overall plan is:
    1. pick which teams are playing
    2. load the two text files into LinkedList variables
    3. each time a goal is scored:
    3a select the team which has scored
    3b select the player who scored and a load of other details

    I'm aware that at step 3b I could load straight from the text file each time, but I thought it'd be quicker to load it once and keep it in memory.


    Thanks for your help, it's much appreciated!
     
  4. GeorgeN

    GeorgeN Well-Known Member

    It sounds like you will be juggling a lot of data. Maybe think about swapping all your text files for an SQLite database (look at the android.database.sqlite package). There are some free gui tools available that you can use to manage all your data.

    SQLite supports atomic transactions. So if you decide to start recording information about when players score, you won't have to worry so much about potential data corruption if the battery dies etc.. It would also make it much easier to compute various player and team statistics.
     
Loading...

Share This Page

Loading...