I have the following code which does nothing but reading some values from a DB in a background thread and using the values I draw a Line chart using a jar.For the line chart I use for value for each array and the problem is that the third that I pass to the constructor that draws the LineChart is float....
float[] viteza;
String[] time;
int contor=0;
public void onResume() {
super.onResume();
init_task = new InitTask();
init_task.execute(db);
}
public class InitTask extends AsyncTask<DBAdapter,String, Void> {
String TABLE_3;
protected Void doInBackground(DBAdapter... db) {
try {
db[0].createDatabase();
db[0].openDataBase();
Cursor c = db[0].getCursor3(db[0].TABLE_3, user_id);
String[] array=new String[2];
viteza = new float[c.getCount()];
time = new String[c.getCount()];
if (c.moveToFirst()) {
do {
publishProgress(c.getString(3),c.getString(4));
Thread.sleep(500);
} while (c.moveToNext());
}
c.close();
db[0].close();
} catch (Exception e) {
Log.d("Eroare", "doInBackground", e);
}
return null;
}
protected void onProgressUpdate(String...values) {
Aitem items[] = new Aitem[1];
viteza[contor]=Float.valueOf(values[0]);
time[contor]=values[1];
if(contor>3)
{
items[0]=new Aitem(Color.RED, "Evolution",viteza);
lv.setTitle("Evolutia vitezei");
lv.setAxisValueX(time);
setContentView(lv);
}
contor++;
}
}
}
I get error at this line:
viteza[contor]=Float.valueOf(values[0]);
java.lang.NumberFormatException:
at org.apache.harmony.luni.util.FloatingPointParser.parseFltImpl(Native Method)
at org.apache.harmony.luni.util.FloatingPointParser.parseFloat(FloatingPointParser.java:321)
Has anyone any clue what is gooing wrong???
EDIT:
In my humble opinion values[0]=c.getString(3) and values[1]=c.getString(4) so ....are Strings...aren't they?