Reputation: 119
I have a Kivy app and I use SQLite Works fine as I work on Win 10 or Ubuntu But when I install the apk on Android I have problems
I use Buildozer VN for the apk , apk seems to work fine When I install it on android, app crashes in time of saving
I guess I have to intilize the SQLite database file on android My question is how and where to do this. My app is a small tutorial and I have the db file in root of main.py I use this command :
con = sqlite3.connect('demo.db')
Where must I put the demo.db on android in order to use it by my app?
Thanks a lot
Kostas
Upvotes: 1
Views: 2906
Reputation: 551
Try this:
import os
app_path = os.path.dirname(os.path.abspath(__file__))
con = sqlite3.connect(os.path.join(app_path, 'demo.db'))
Note: If you want to upload the db when building the app maybe you should include the extension in buildozer.spec file
# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas, ttfs, json, db
Upvotes: 2