I am using SQLite in a project used by an android application. Currently I am using the SQLite implementation provided in android.database.sqlite
.
I want to make a desktop application which uses the same codebase. So I need to separate all the shared behaviour into a separate portable project/jar.
My problem is I'm currently making heavy use of android.database.sqlite
. If possible I do not want to re-write every database access call to be compatible with JDBC or whatever I will have to use without using the android provided SQLite.
To solve this problem with minimal impact on the existing code. I intent to write a SQLite interface (compatible with android.database.sqlite
) which the shared code will use... on android it will be implemented trivially by android.database.sqlite
, and on the desktop it will be implemented by somehow mutilating SQLite through JDBC to match android.database.sqlite
.
This is proving difficult as I often supply Object[]
arrays to be bound to prepared statements which JDBC requires strict typing, and I am not familiar with JDBC at all.
Is there any other way to use SQLite in Java which is similar to android.database.sqlite
, or any other approaches which may save me the effort (and inevitable debugging) associated with re-writing many database access points?
Disclamer: I have never until now tried using JDBC.
Simplified question: What is the best way to use SQLite in java? JDBC, other?