Page 1 of 1

Sqlite for Android

Posted: 12.08.2021, 21:48
by cayqued
Hello. Does ZeosLib support Sqlite for Android?

When trying to connect I get the following error: "System Error. Code: 20. Nota directory."

Test Code:

Code: Select all

ZConnection1.LibraryLocation := TPath.Combine(TPath.GetDocumentsPath, 'libsqlite.so'); 
ZConnection1.Database := TPath.Combine(TPath.GetDocumentsPath, 'db_sqlite.db');
ZConnection1.Protocol := 'sqlite'; 
ZConnection1.ClientCodepage := 'UTF-8'; 
ZConnection1.Connected := true;
Thanks.

Re: Sqlite for Android

Posted: 13.08.2021, 09:52
by marsupilami
Hello,

Zeos supports sqlite on Android. We had a library loading bug on Android that should be fixed with the latest revision of Zeos 8.0. Please update your Zeos and let me know if it solves your problem.

Best regards,

Jan

Re: Sqlite for Android

Posted: 13.08.2021, 20:13
by cayqued
Hi. Thanks for the feedback.
I ran the tests again after downloading version 8.0 and now the following error occurs: System error. Code: 11. Try Again.

I'm testing with the sqlite-3.3.8.so library provided by the project and another library generated by me.
I'm putting the file inside ".\assets\internal" in remote path in Delphi deployment.
Tested on Android 32-bit and 64-bit, Xiaomi Mi 8 Lite.

Re: Sqlite for Android

Posted: 14.08.2021, 09:28
by marsupilami
This is strange. I couldn't find a library for download on sqlite.org. I extracted the libsqliteX.so from the sqlite-android-3360000.aar:
  • Rename the aar file to be a zip file
  • extract it
  • find the library in the jni\armeabi-v7a subdirectory
This is my source code:

Code: Select all

    ZConnection1.LibraryLocation := TPath.Combine(TPath.GetHomePath, 'libsqliteX.so');
    DbLocation := TPath.Combine(TPath.GetDocumentsPath, 'db_sqlite.db');
    Memo1.Lines.Append(DbLocation);
    ZConnection1.Database := DbLocation;
    ZConnection1.Protocol := 'sqlite';
    ZConnection1.ClientCodepage := 'UTF-8';
    ZConnection1.Connected := true;
    Memo1.Lines.Append(BoolToStr(FileExists(DbLocation), True));
The last line of the source code tells me that the database file got created successfully.

My deployment settings tell Delphi to deploy the libsqliteX.so file to ".\assets\internal\".

I tested this only as a 32 bits application on a Samsung Note 10 having Android version 11.

Re: Sqlite for Android

Posted: 16.08.2021, 12:57
by cayqued
Hi. I followed your way of doing and managed to connect. Thanks.