🟥 [FREE] SimpleSqlite - an extension for working with SQLite Databases

Hi,

My data don't get written to sqlite from screen login. I use the same setup in screen1 and there it works.

The strangest thing is that I have managed to store data once from the login screen after setting file permissions (that magically turned off). Thought that solved it, but afterwards could not reproduce the result.

Can it be that the problem is that I don't use Screen1?


Put your database in the assets, import it from there to the default database, then export it to /Documents. That way your app owns the exported copy.

Then import the database from /Documents so that you can then read and write.

Then set the database name to the one in /Documents so that you can then read and write.

OK. Thanks a million I will try that!

I tried it. The db is created in /Documents but still no data being written to it...

I think I am going to do the login from screen1 using visibility to switch what's on the screen.

Looks like it is not happy working directly with the database in /Documents (not sure why, will need to investigate further). However you can import that database to the default database, work with it, then export it again once finished.

Looks messy (and it is...)

On first run, import the db from assets, then export to /Documents (use tinydb to prevent this from happening again)

Then import the db from /Documents to the default database

Work with it.

When finished export the db to /Documents

OK. Thank you once more!

You may be able to use the db you placed in /Documents in the first place, if you import it ?

Seems to work OK if the db is saved/exported to the ASD, then set as DBName with that path, but not for paths to shared storage, possibly an Android 13 thing I have not come across. [EDIT - nope, just wasn't in the extension - fixing]

Update to V4krelease

  • now allows for the export and dbNaming of databases to Shared Directories - Download or Documents
  • it is important to use an absolute path to the Shared Directories:
    • e.g. /storage/emulated/0/Download/mysqlite.db
    • use this to either export the database, or to set the DBName property, which will then allow you to open the database in the usual way.

This error also happened to me. I found it happens if we uninstall the app then reinstall it.
or if we delete the db then install again.
and it will return to normal if the DB name in the asset is changed then rebuilt then installed again

I first like to thank TIMAI2 for this extension SimpleSQLite., very crucial for Database related access, moreover it has been given free to everyone.

Now the problem:
There is SimpleSQLite in Screen1, when SimpleSQLite is added to Screen2 or Screen3, then The app freezes, while trying to open Screen2 or Screen3 .
I suppose SimpleSQLite is unique to every Screen. I don't know why it happens?

Thanks and regards
Stephen

Don't remember this being an issue previously, not heard of this before. I have tested a 3 screen project in companion, with SimpleSqlite loaded in each screen (not doing anything) and I see no crashing.

Are you closing/unloading databases before switching screens ?

Do you need multiple real screens, you could probably use virtual screens for your app

I have attached the .aia file with modification adding Screen4 .

When the Search button in Screen1 is clicked, Screen4 opens but takes time and the app freezes.

Please, Let me know why it is so?

Thanks and regards
St
Bible (1).aia (515.2 KB)
ephen

I am looking

Why are you using V2 of SimpleSQLite? Use the latest version V4 which includes the listFixer method along with other improvements.

You appear to have got yourself into a muddle. You only have one bible database, so why does the user have to pick a file from Shared Directories ? Just import it to the main database from assets and work from there, or as I did in my previous example, download it to your ASD and set the filepath there.

Different real screens should be considered as different apps, you need to ensure you close the database on one screen before loading and opening the database on another. This I why I suggested virtual screens.

9 posts were split to a new topic: Error with apk build (own local AppInventor)


Hello TIMAI2,

I'm encountering a problem with the return values from what appears to be the sql.run function. It seems that if the query finds matching records, the function correctly returns the data. But if no records are found, it returns the string "SQL command completed" instead of an empty list.

This makes the data handling logic more complicated, as I have to check the result type before processing it.

What is the recommended way to handle this scenario? I was expecting an empty list for a query with no results.

Thanks for your help.

confirmed.

I will take a look, see what can be done.

Try this:

uk.co.metricrat.simplesqliteV4.12.aix (22.5 KB)

(needs testing "in the wild")

I have replaced:

    if (task.rows.size() == 0) {
      return YailList.makeList(Arrays.asList("SQL command completed"));
    } else {
      return YailList.makeList(task.rows);
    }

with

   if (sql.toLowerCase().contains("select") && task.rows.size() > -1) {
      return YailList.makeList(task.rows);
    }
    else if (task.rows.size() > 0) {
      return YailList.makeList(task.rows);
    } 
    else {
      return YailList.makeList(Arrays.asList("SQL command completed"));
    }
1 Like

I will try, thanks for your help