SQlite and ListView

Hello.
I have about 65,000 rows in the SQLite dbLekari asset. I just want to show some, by select in ListView ...
I'm trying to populate ListView from select db. Each tblLekari line in dbLekari has 2 columns. Do I have to do it through List or something?
Ondrej


Connecting source ....

Looks OK, except for the last part. With Taifun's extension, the data comes back as csv table text.

Thanks !!!

Ondrej

Hello.
The program via Companion works OK. But when I compile it via Build, it crashes on the mobile with the message:
Syntax Error: quote in unquoted cell Cannot parse text argument to "list from csv table" as a CSV-formatted table.
Can anyone advise?
Ondrej

You appear to be using two different SQLite extensions at the same time? Why ?

With regard to your error, check the raw output of the query, and your base data, it seems you have an extra quote or character somewhere that breaks the csv table formatting.

Hello.
I didn't find all the necessary methods I need in the TaifunSQLite1 extension, so I added the SQLite1 extension. Is it a mistake?
Question:

  • ImportDatabase creates a byte copy of the specified SQLite database file (db is in assets) in the development environment. When I do the Build project and install the mobile apk, do I need to do the ImportDatabase on the mobile again?
    Ondrej

It depends on what you are doing.....

With Taifun's extension, if you import a database, this becomes the current database and it is open and ready to accept sql commands. When your work is done, you can export the database to a filename.

With the Bennedum extension, the current database needs to be closed, then you can import a database, then you must open it to work with it. You can then export the database, but you must close it first.

For both extensions, and this can often be the confusing part, there is an underlying current database (main). The easiest approach is to do as above, and import/export your actual database to this underlying database and work with it. By exporting when work is done, you have an up to date copy of your database on file, ready for importing next time.

It is also possible to ATTACH a database to the underlying database:

ATTACH DATABASE '/path/to/sqlite.db' AS myDb;

You can then work with both the underlying db and the attached one:

SELECT * FROM myDb.myTable WHERE id = 5

Hello.
I guess I don't understand that well ...
I definitely want db to be part of the apk and so that the client doesn't have to worry about its location in any directory on the mobile ...
I imagined it like this:

  • I will move db SQLite in the development environment to Media.
  • I will ensure the creation of a byte copy of the specified database file within the development environment during the first transition of the program.
  • That's how it worked ....
  • Then I make an .apk through the Build development environment.
  • I will transfer the created .apk to the mobile phone ....
  • Is it good practice or is there a mistake?

Regarding the use of SQLite extensions:
can I do this by not using the Bennedum extension?
I will only use TaifunSQlite1.
I only use that db for reading.
Please don't have any link where only TaifunSQlite1 is used and it works?
Thanks.
Ondrej

See the documentation on the Taifun SQLite page, that should tell you what you need to know. You should not need the Bennedum extension.

If you load your db as an asset, you can then import it.

If you want to edit/update the database, then you will need to export it to another database file on your read/writeable sdcard - e.g. application specific directory (ASD), and then import that database to continue working. Alternatively you can just work with the underlying database.

Hello.
I fired Bennedum from the extension. Only TaifunSqlite1 remained.
The dbLekari.db database is in the Media development environment.
When I try Al Companion I get an error ... in the attachment
I looked at that example App Inventor Extensions: SQlite | Pura Vida Apps
I guess I misunderstood it ...
Ondrej


1 Like

Close your companion and connection, then open it up again, you need to do this to flush out the other extension. For good measure restart/refresh your AI2 as well.

  1. use only one sqlite extension
  2. what exactly do you think is missing in my extension?

Taifun