Stulish Active Member Licensed User Longtime User Nov 22, 2012 #1 Hi, My app transfers data via serial communications, the data is in a string format. my app seems to run ok but at times it will sometimes throw up and invalid double error, this normally happens if some of the sentances have not been sent and the the fields are blank. java.lang.NumberFormatException: Invalid double: "" at java.lang.StringToReal.invalidReal(StringToReal.java:63) at java.lang.StringToReal.parseDouble(StringToReal.java:248) at java.lang.Double.parseDouble(Double.java:295) at android.lishsoft.smids.main._popnmea(main.java:1047) at android.lishsoft.smids.main._recievetimer_tick(main.java:1233) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165) at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:103) at android.os.Handler.handleCallback(Handler.java:605) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4517) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760) at dalvik.system.NativeStart.main(Native Method) java.lang.NumberFormatException: Invalid double: "" Click to expand... My understanding was if i have a string that contains "00.03" in a variable SomeString and then i create a variable SomeDouble by: Code: Copy Dim SomeDouble as double when i use the following it should convert the string to a double automatically: Code: Copy SomeDouble = SomeString is this thinking correct? what is the outcome if the string contains nothing? i have tried to catch the error using an if statement to say Code: Copy if SomeString<>"" then SomeDouble=SomeString basically if the string contains nothing then do not do the conversion, but i still get the error nothing seems to work
Hi, My app transfers data via serial communications, the data is in a string format. my app seems to run ok but at times it will sometimes throw up and invalid double error, this normally happens if some of the sentances have not been sent and the the fields are blank. java.lang.NumberFormatException: Invalid double: "" at java.lang.StringToReal.invalidReal(StringToReal.java:63) at java.lang.StringToReal.parseDouble(StringToReal.java:248) at java.lang.Double.parseDouble(Double.java:295) at android.lishsoft.smids.main._popnmea(main.java:1047) at android.lishsoft.smids.main._recievetimer_tick(main.java:1233) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165) at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:103) at android.os.Handler.handleCallback(Handler.java:605) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4517) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760) at dalvik.system.NativeStart.main(Native Method) java.lang.NumberFormatException: Invalid double: "" Click to expand... My understanding was if i have a string that contains "00.03" in a variable SomeString and then i create a variable SomeDouble by: Code: Copy Dim SomeDouble as double when i use the following it should convert the string to a double automatically: Code: Copy SomeDouble = SomeString is this thinking correct? what is the outcome if the string contains nothing? i have tried to catch the error using an if statement to say Code: Copy if SomeString<>"" then SomeDouble=SomeString basically if the string contains nothing then do not do the conversion, but i still get the error nothing seems to work
eps Expert Licensed User Longtime User Mar 28, 2014 #21 Internal can be external... It's a bit of a contradiction, it's more that the directory is internal to your App. If you are writing files for your App do something like this : Code: Copy TextWriteLine.Initialize(File.OpenOutput(File.DirInternal, "refresh_setting.txt", False)) DirInternal can be internal or external storage, but if you use DirInternal it will always work and it won't actually matter where it's stored, the App will know. HTH - any more questions please start a new thread. Upvote 0
Internal can be external... It's a bit of a contradiction, it's more that the directory is internal to your App. If you are writing files for your App do something like this : Code: Copy TextWriteLine.Initialize(File.OpenOutput(File.DirInternal, "refresh_setting.txt", False)) DirInternal can be internal or external storage, but if you use DirInternal it will always work and it won't actually matter where it's stored, the App will know. HTH - any more questions please start a new thread.
klaus Expert Licensed User Longtime User Mar 28, 2014 #22 If the file is only used by your program use DirInternal. If the file must be accessible to other applications use DirRootExternal or DirDefaultExternal. Upvote 0
If the file is only used by your program use DirInternal. If the file must be accessible to other applications use DirRootExternal or DirDefaultExternal.