Error using SaveCSV

splatt

Active Member
Licensed User
Longtime User
I'm trying to write some persistant values to a CSV file:

B4X:
Sub SaveValues
   Dim su As StringUtils
   Dim table As List
   Try
      table.Initialize
      table.AddAll(Array As String("ExtDir",ExtPegDir))
      table.AddAll(Array As String("CatFile",PegSet))
      table.AddAll(Array As String("BGDir",ExtBGDir))
      table.AddAll(Array As String("BGFile",CurrentBG))
      table.AddAll(Array As String("Side",LeftOrRight))
      su.SaveCSV(File.DirRootExternal&"/Android/data/encoded.b4a/files", "encoded.csv", ",", table)
   Catch
      Log("SaveValues - "&LastException.Message)
   End Try
End Sub

I'm getting this error:
SaveValues - java.lang.ClassCastException: java.lang.String

The values I'm adding are these:
ExtDir - /mnt/sdcard/Android/data/encoded.b4a/files/encoded/Alternate Pegs/Numbers
CatFile - Numbers.cat
BGDir - ""
BGFile - wood_grain.gif
Side - Right

Any suggestions as to what may be causing the cast error?
 

splatt

Active Member
Licensed User
Longtime User
I have rewritten my SaveValues and ReadValues routines using Maps. These work very well.

However, I would still like to try and resolve the cast error above, as I have tried using SaveCSV a few times now and have always had the same problem.

Any advice greatly appreciated.
 
Upvote 0

rayzrocket

Member
Licensed User
Longtime User
i get the same error, here is the LogCat

The list that needs to be written to a csv file is in a module named FService.

Code:
Dim su As StringUtils 'in future use CSV2 that includes a settings header line(from a list)
su.SaveCSV(DumFolder,DumFile,",",FService.DataSetService) 'adds .csv to make a new file
ToastMessageShow("Data Saved To .csv File", False)

LogCat:
LogCat connected to: B4A-Bridge: samsung SAMSUNG-SGH-I727-357288040143489
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
main_savedatabut_click (B4A line: 213)
su.SaveCSV(DumFolder,DumFile,",",FService.DataSetService) 'adds .csv to make a new file
java.lang.ClassCastException: [F
at anywheresoftware.b4a.objects.StringUtils.SaveCSV2(StringUtils.java:89)
at anywheresoftware.b4a.objects.StringUtils.SaveCSV(StringUtils.java:82)
at com.avidlp.frog103.main._savedatabut_click(main.java:1703)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:158)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:154)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:54)
at android.view.View.performClick(View.java:2582)
at android.view.View$PerformClick.run(View.java:9252)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
at dalvik.system.NativeStart.main(Native Method)
java.lang.ClassCastException: [F
 
Upvote 0
Top