Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old April 20th, 2012, 03:16 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Apr 2012
Posts: 3
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Help for a rusty coder

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!

Force39 is offline  
Reply With Quote
sponsored links
Old April 21st, 2012, 10:54 AM   #2 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,936
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 478 Times in 292 Posts
Default

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?
jonbonazza is offline  
Reply With Quote
Old April 23rd, 2012, 01:10 PM   #3 (permalink)
New Member
Thread Author (OP)
 
Join Date: Apr 2012
Posts: 3
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by jonbonazza View Post
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.
I can live with that, I'll have a look into SharedPreferences

Quote:
Originally Posted by jonbonazza View Post
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.
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.

Quote:
Originally Posted by jonbonazza View Post
3) What do you wish to do with the data once accessed?
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!
Force39 is offline  
Reply With Quote
Old April 23rd, 2012, 02:42 PM   #4 (permalink)
Junior Member
 
Join Date: Apr 2012
Location: London
Posts: 98
 
Device(s): ZTE Skate, Ainol Novo7 Aurora
Carrier: Not Provided

Thanks: 2
Thanked 24 Times in 23 Posts
Default

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.
GeorgeN is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:17 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.