Android Question DBUtils Question

grant1842

Active Member
Licensed User
Longtime User
I am looking at Dbutils .
B4X:
DBUtils.CopyDBFromAssets("cb.db")
    DBUtils.ExecuteListView(SQL,"Select * From Radio",Null ,0,ListView1,False)

I have a local database I want to copy it to the phone and use it.
I am just trying to display the records from the radio table.
I run it and it crashes.
B4X:
    at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Create, isFirst = true **


Error occurred on line: 188 (dbutils)


mainafterFirstLayout (java line: 98)


java.lang.RuntimeException: Object should first be initialized.
    at anywheresoftware.b4a.sql.SQL.checkNull(SQL.java:48)
    at anywheresoftware.b4a.sql.SQL.ExecQuery(SQL.java:154)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:485)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:229)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:174)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
    at gdf.grantfullen.cbtipsandtricks.main.afterFirstLayout(main.java:98)
    at gdf.grantfullen.cbtipsandtricks.main.access$100(main.java:16)
    at gdf.grantfullen.cbtipsandtricks.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4938)
    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:1038)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
    at dalvik.system.NativeStart.main(Native Method)
What am I doing wrong here ?
 

grant1842

Active Member
Licensed User
Longtime User
B4X:
SQL.Initialize(File.DirInternal,"cb.db",True)
    DBUtils.CopyDBFromAssets("cb.db")
    DBUtils.ExecuteListView(SQL,"Select Radio.* From Radio",Null ,0,ListView1,False)
Now it saying there is no such table as Radio. And there is of course.
B4X:
android.database.sqlite.SQLiteException: no such table: Radio (code 1): , while compiling: Select Radio.* From Radio

Is there something im not doing here ?
Thanks
 
Upvote 0

grant1842

Active Member
Licensed User
Longtime User
Ohh thanks for the help.
Here Was issue
B4X:
SQL.Initialize(File.DirDefaultExternal,"cb.db",True)
Thanks for the help.
 
Upvote 0
Top