Note that there are some explanatory texts on larger screens.

plurals
  1. POHow cast from Float in object array to float variable?
    primarykey
    data
    text
    <p>Hi I retrieve data and one Float value from sqlite and return in arraylist:</p> <pre><code>if (!cursor.isAfterLast()) { do { .... rowArray.add(cursor.getFloat(2)); .... } while (cursor.moveToNext()); } </code></pre> <p>Problem occurred in float cast, when I try to set float variable from the list:</p> <pre><code>ArrayList&lt;Object&gt; row; row = db.getNameAsArray(name); mCurrentPrice=((Float)row.get(2)).floatValue(); </code></pre> <p>There is no error but app FC in this line. Simple float cast doesnt work neither. Thx for any answer.</p> <p>Logcat:</p> <pre><code>02-07 22:34:19.537: ERROR/Retrieve Error(632): java.lang.ClassCastException: java.lang.String </code></pre> <p>02-07 22:34:21.217: WARN/System.err(632): java.lang.ClassCastException: java.lang.String 02-07 22:34:21.267: WARN/System.err(632): at com.testing.retrieveDrinkName(DatabaseActivity.java:222) 02-07 22:34:21.527: WARN/System.err(632): at android.os.Handler.handleCallback(Handler.java:587) 02-07 22:34:21.547: WARN/System.err(632): at android.os.Handler.dispatchMessage(Handler.java:92) 02-07 22:34:21.596: WARN/System.err(632): at android.os.Looper.loop(Looper.java:123) 02-07 22:34:21.657: WARN/System.err(632): at android.app.ActivityThread.main(ActivityThread.java:4363) 02-07 22:34:21.667: WARN/System.err(632): at java.lang.reflect.Method.invokeNative(Native Method) 02-07 22:34:21.737: WARN/System.err(632): at java.lang.reflect.Method.invoke(Method.java:521) 02-07 22:34:21.769: WARN/System.err(632): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 02-07 22:34:21.797: WARN/System.err(632): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 02-07 22:34:21.817: WARN/System.err(632): at dalvik.system.NativeStart.main(Native Method)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload