I read some posts you wrote and also I seen a picture reassuming the situation, that is clear. It is not clear to me why if a DB is in the Media, and so it means it is in /storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/assets/, is not found by AI2 or by the extension, seems that everything is right.
This path is useful when testing in companion, the assets folder is a special folder generated by the companion app to provide debugging access to media files. In compiled apps the path to assets/media files is different. Your sqlite extension may not be written to accept the //
syntax for assets, therefore you would need to access the assets in another way, or as previous suggested, copy your assets to the ASD for ease of use.
The extension accept the path written as /storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/assets/mydb.sqlite and works because it reads the tables and records already present. So, considering I did not want to modify the source code to manage test and production releases I have to find the best solution to deliver the DB inside the apk and for the application to know that the dB may be in one place or in the other. I do not know how I can delivery the DB in a different way than uploading it in the Media, is there a different option?
Do you need to edit the database, or just read from it ?
in this case I need just to read but I would prefer to have a solution that may work also to write. I am using an extension made by you that returns the assets path, does it return a different result working with companion or without? Because with companion it works perfeclty, if it returns the assets path accordingly if the app works with companion or without (I mean an apk installed on the phone) could be the simplest solution.
I made some tests and now the situation is a little bit more clear. I am able to test and debgu using Companion, the DB is located in /storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/file/assets/mydb.sqlite This path is returned calling the methods of SQLite extension and also your tools extension. Testing the apk the results are different. Your tools extension (and another couple of similar extensions) return /storage/emulated/0/Android/data/appinventor.ai_massimomanca_es.TestSQLite/files and the SQLite1.DatabasePath returns /storage/emulated/0/android_asset
But android_asset does not exist and also I did not find any other mydb.sqlite DB anywhere else. So, where AI2 copies mydb.sqlite installing the apk? I need a good file finder tool working on Android...
The sqlite extension is out of date (not likely to be updated) and not handling the new compiled path to assets. It also cannot cope with being fed the PathToAssets blocks from Taifun's Tools extension, and crashes the app.
Because of this you should try as I suggested and copy the database to your ASD, as in my blocks above, then access it from there (which also gives you read/write)
Your alternative is to use Taifun's SQLite extension, which is up to date and full support is provided. I would recommend this course of action given your determination to access the database from assets when compiled.
(note: the File extension is also by Taifun, not me...)
Is there really a new path to the assets for the APK?
Since when?
Honestly, at the moment I am a little bit confused... I have too many different results. I am sure that someone depends by the extension(s) but someone is coming from Android 11. I think that the simpler thing from a management point of view is find a way so that uploading a DB on the Media it will work both with Companion and apk. It may be a little bit more complicated to realize but seems to me that is the way to solve and prevent any DB update problems.
Exactly, seems there is something wrong in the SQLite extension about default path management.
31 posts were split to a new topic: Webviewer - HTML embedded image - path to assets / Shared folder
I have also researched about this problem and in essence, there are two problems:
-
The SQLite Extension (bennedum.SQLite) has a bug, because it hardcodes the path to the SQLite database file, so when App Inventor is updated (along with update to Android 10), the extension cannot import uploaded asset file anymore.
-
Android 10 fails to read (well, actually fails to copy from asset folder to ASD folder) if the file is compressed in the distributed apk file. Because media files (with media-files-extension of png, mp3, etc.) are not compressed again in the apk file, Android 10 successfully copy them. So, the solution for this problem is to use change to uploaded file extension to become media-file extension (png, mp3, jpg, etc.).
I got the idea after reading a discussion about how to pass file from assets folder to native program (C++). The link to the discussion is here https://groups.google.com/g/android-ndk/c/ppCEAY6Hpag and the part of the discussion that relates to this problem is here:
The general work around solution for both the problems (no. 1 and 2) is to (i) upload sql-statement file that build the table(s) for the first time (and insert some initial data) with a media-file-extension, (ii) using block-code to copy the file from asset folder to application specific folder and (iii) then split the sql-statement file into several sql-statements and (iv) execute all the sql-statements.
Do you have a working example of this? My experiments in renaming file extensions for non media files did not work ..
Here is a working example. I hope it helps...
And the aia file...
Sistem_Informasi_RS.aia (126.0 KB)
I (and most) don't have time to reconstruct your project,
aia - please.
I cannot see any need for the file to have the sufffix .png
(if it is a text file) when stored in the assets / media folder. This folder is only readable by the app itself....and can easily be opened with the File component.