EDIT: SOLVED AS IM A TOTAL FOOL and didnt notice the file name was wrong between my 2 activities. Never mind, thanks to all those that helped. Still learning, just hope i can stop re-learning very old lessons!
im new to android and java and am trying to do what seems simple, but am struggling and am not sure why.
I want to load a string from a text file and extract the numbers from the string as an int for use elsewhere in my app. I want to use the int then in an array for use with androidplot to draw a graph, i have the graph working with a manual array (ie just type some random numbers in myself) so have omitted most of that code from here for simplicity.
This is my code for the load fo the txt file, split it at " " and then parse the int, but it isnt working.
//actually load the progress file
public void loadDatacomm() {
//load the asset file
StringBuilder text = new StringBuilder();
try {
BufferedReader br = new BufferedReader(new FileReader("/sdcard/.progress/1gppi.txt"));
String line;
while ((line = br.readLine()) != null) {
String line2[] = line.split(" "); //split the string to get the progress
commprogress1 = Integer.parseInt(line2[0]);
}
}
catch (IOException ex) {
return;
}
The only other bit of interest i guess is the array in android plot which i am building like this;
Number[] commprogress = {commprogress1, commprogress2, commprogress3, commprogress4, commprogress5, commprogress6, commprogress7, commprogress8, commprogress9, commprogress1};
When i load the activity then the graph doesnt show any value, if i manually declare values of the commprogress1, 2, 3, then the graph draws fine.
Can someone help me please?
EDIT the file i am trying to load contains the following:
30 %complete
It is written by another activity in the application.
I have no idea why the code isnt working, I am using similar code elsewhere in the application to extract the int (in this case 30) from the split string, but its not working here.