Pretty sure this is an easy one, but i'm getting confused by all the examples that adapt the data returned from a cursor into different views. I just want to run a rawquery and put each item of data returned into a float array (so that i can add them up later). What do i need to use for this? Thanks
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
You'll still have a cursor when you query your database, but once you got the cursor you could iterate over it, pulling out the values you need into an array, like this:
Don't minus by 1 in
float[] myFloats = new float[cursor.getCount()-1];
because (int i =0) or i start from 0. If you use it, will appearJava.lang.IndexOutOfBoundsException
. You need array index until[cursor.getCount()]
, not until[cursor.getCount()-1]
. So the correct thing isfloat[] myFloats = new float[cursor.getCount()];