I listed all the contacts i have on the phone on a list, now i wanted to save the list to CSV but i always get errors on the emulator.
Dim su As StringUtils
su.SaveCSV(File.DirRootExternal, "1.csv", ",", table)
i'm doin'g it like on the tutorial's you have, with savecsv and savecsv2 and none seems to work. is it a bug on the emulator?
java.lang.ClassCastException: java.lang.String
at anywheresoftware.b4a.objects.StringUtils.SaveCSV2(StringUtils.java:74)
at
anywheresoftware.b4a.objects.StringUtils.SaveCSV(StringUtils.java:67)
at contacts2.csv.droidman.main._savecontacts_click(main.java:277)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:99)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:89)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:85)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:49)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3647)
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:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
java.lang.ClassCastException: java.lang.String
LogCat connected to: B4A-Bridge: HTC HTC Magic/Dream-##########
--------- beginning of /dev/log/system
--------- beginning of /dev/log/main
Connected to B4A-Bridge
Installing file.
PackageAdded: package:convert.kgm.droidman
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
main_savecontacts_click (B4A line: 80)
su.SaveCSV(File.DirRootExternal, "1.csv", ",", list1)
java.lang.ClassCastException: java.lang.String
at anywheresoftware.b4a.objects.StringUtils.SaveCSV2(StringUtils.java:74)
at anywheresoftware.b4a.objects.StringUtils.SaveCSV(StringUtils.java:67)
at convert.kgm.droidman.main._savecontacts_click(main.java:277)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:99)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:89)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:85)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:49)
at android.view.View.performClick(View.java:2501)
at android.view.View$PerformClick.run(View.java:9107)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3848)
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:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
java.lang.ClassCastException: java.lang.String
i'm really not finding the problem.
do i have to make a FOR cicle and save each line or just call it
su.SaveCSV(File.DirDefaultExternal, "1.csv", ",", list1)
thanks for your help. I did that modification and now the program "explodes" at "list1.Sort(True)" probably because the emulator restarted and now it does not have the contacts i created before.
so this validation could be done in 2 ways i did know in vb and .net wich are checking if the list contains any ittems and then validating and the other one was the BAD way to do it that was "on error resume next"
wich by the way, is there any way to do that on basic4android ?