I need to get a value from my cursor. The value needs to be in this format:
List<double[]> values = new ArrayList<double[]>();
The problem is when I do the “.add” it errors wanting me to change it to “length”. I have to have it in the List for the app to work at all. Here is my code, is there a way to do that? What am I doing wrong?
cursor = managedQuery(Provider.CONTENT_URI,
proj,
null,
null,
null);
while (cursor.moveToNext()) {
double value;
column_value = cursor.getColumnIndex(CsvProvider.VALUE);
value = cursor.getDouble(column_value);
values.add(value); //this did not work
values.add(new double[] {value}); //this did work
} ;
Thanks Mike!
First of all, you should never paraphrase errors. If you get an error, copy and paste it into your question.
As to your problem:
You have a list of double arrays, i.e. every single entry in your cValues List needs to be a double[]. Instead, however, you’re just adding a plain double. That won’t work. I don’t know how your list is supposed to be setup, if you put the [] in by mistake or if you really need a list of arrays, but assuming that every entry needs an array of one double, then you need to add a
new double[] { value }.Side note: Why not simply
while (cursor.moveToNext()) { ... }instead of this do/while construct?