forked from bolav/fuse-sqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSQLiteImpl.Android.uno
42 lines (35 loc) · 1.29 KB
/
SQLiteImpl.Android.uno
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Fuse;
using Uno.Compiler.ExportTargetInterop;
using Uno.Collections;
using Bolav.ForeignHelpers;
// http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html
public extern(Android) static class SQLiteImpl {
[Foreign(Language.Java)]
public static extern Java.Object OpenImpl(string filename)
@{
return android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(filename, null);
@}
[Foreign(Language.Java)]
public static extern void ExecImpl(Java.Object db, string statement, string[] param)
@{
((android.database.sqlite.SQLiteDatabase)db).execSQL(statement, param.copyArray());
@}
[Foreign(Language.Java)]
public static extern void CloseImpl(Java.Object db)
@{
((android.database.sqlite.SQLiteDatabase)db).close();
@}
[Foreign(Language.Java)]
public static extern void QueryImpl(ForeignList fl, Java.Object db, string statement, string[] param)
@{
android.database.Cursor curs = ((android.database.sqlite.SQLiteDatabase)db).rawQuery(statement, param.copyArray());
curs.moveToFirst();
while (!curs.isAfterLast()) {
Object row = @{ForeignList:Of(fl).NewDictRow():Call()};
for (int i=0; i<curs.getColumnCount(); i++) {
@{ForeignDict:Of(row).SetKeyVal(string,string):Call(curs.getColumnName(i), curs.getString(i))};
}
curs.moveToNext();
}
@}
}