Android Question SQLite Viewer

Rajesh Krishnan

Member
Licensed User
Hey!
On executing the sqlite viewer code and on loading the db from my drive i get an error telling error loading DB could anyone please help me with this.
 

Rajesh Krishnan

Member
Licensed User
Where is the database stored?

Can you post the error message from the logs?
The Database is stored locally on my D:drive and for the purpose of using using it for the upload i stored it on my drive so that when it asks for choosing a file from the file manager i could choose from my drive. And the error is when i choose the DB file from the drive that i have uploaded to, which says "Error loading database."
 
Upvote 0

eps

Expert
Licensed User
Longtime User
But it needs to reside in the /files subdirectory under where your App code is located.

You're not really giving us much to go on to help you!!

At what stage do you get the error - execution? generation? What SQL Viewer code?? What does your code look like?
 
Upvote 0

Rajesh Krishnan

Member
Licensed User

The error appears after the execution of the code and yes i do have the DB file reside in the files subdirectory where my app code is located, i have as well saved this DB file on my drive so that after execution of the code when it asks to choose the DB from my android device i am able to choose it from my drive, the code that i have used is this one that i have attached below, Thanks
 

Attachments

  • SQLiteViewer.zip
    10.4 KB · Views: 299
Upvote 0

eps

Expert
Licensed User
Longtime User
Where's the Database?

Hmm.... I think you'll need to know the location of the database - you seem to want the User to supply a directory and filename for a given DB - I don't know what that is on my device - sorry!

I would look at the try catch you have, either log some values to see if a wrong value is being passed in to it or trace through the code.

B4X:
    If SQL.IsInitialized Then SQL.Close

    Try

        SQL.Initialize(Dir, FileName, False)

        DBUtils.ExecuteListView(SQL, "SELECT name FROM sqlite_master WHERE type = 'table'", Null, 0, lstTables, False)       

        lblDatabase.Visible = True

        lblDatabase.Text = "Database: " & FileName

        lblChooseTable.Visible = True

        lblBasic4android.Visible = False

        Label2.Visible = False

    Catch

        ToastMessageShow("Error loading database.", True)

        lblDatabase.Visible = False

        lblChooseTable.Visible = False

    EndTry
 
Last edited:
Upvote 0

eps

Expert
Licensed User
Longtime User
I use something like this

B4X:
                            If SQL1.IsInitialized = False Then

                                SQL1.Initialize(File.DirInternal,"thedatabase.db", True)

                            End If
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…