Skip to content

Commit dbb4be6

Browse files
committed
docs: compact Android package section
1 parent 3d13cc3 commit dbb4be6

File tree

1 file changed

+13
-70
lines changed

1 file changed

+13
-70
lines changed

README.md

Lines changed: 13 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -65,84 +65,27 @@ sqlite3_close(db)
6565

6666
### Android Package
6767

68-
You can [add this project as a dependency to your Android project](https://central.sonatype.com/artifact/ai.sqlite/js).
68+
Add the [following](https://central.sonatype.com/artifact/ai.sqlite/js) to your Gradle dependencies:
6969

70-
**Groovy:**
7170
```gradle
72-
repositories {
73-
google()
74-
mavenCentral()
75-
maven { url 'https://jitpack.io' }
76-
}
77-
dependencies {
78-
// ...
79-
// Use requery's SQLite instead of Android's built-in SQLite to support loading custom extensions
80-
implementation 'com.github.requery:sqlite-android:3.49.0'
81-
// Both packages below are identical - use either one
82-
implementation 'ai.sqlite:js:1.1.11' // Maven Central
83-
// implementation 'com.github.sqliteai:sqlite-js:1.1.11' // JitPack (alternative)
84-
}
71+
implementation 'ai.sqlite:js:1.1.12'
8572
```
8673

87-
**Kotlin:**
88-
```kotlin
89-
repositories {
90-
google()
91-
mavenCentral()
92-
maven(url = "https://jitpack.io")
93-
}
94-
95-
dependencies {
96-
// ...
97-
98-
// Use requery's SQLite instead of Android's built-in SQLite to support loading custom extensions
99-
implementation("com.github.requery:sqlite-android:3.49.0")
100-
// Both packages below are identical - use either one
101-
implementation("ai.sqlite:js:1.1.11") // Maven Central
102-
// implementation("com.github.sqliteai:sqlite-js:1.1.11") // JitPack (alternative)
103-
}
104-
```
105-
106-
After adding the package, you'll need to [enable extractNativeLibs](https://github.com/sqliteai/sqlite-extensions-guide/blob/18acfc56d6af8791928f3ac8df7dc0e6a9741dd4/examples/android/src/main/AndroidManifest.xml#L6).
107-
10874
Here's an example of how to use the package:
10975
```java
110-
import android.database.Cursor;
111-
import android.util.Log;
112-
import io.requery.android.database.sqlite.SQLiteCustomExtension;
113-
import io.requery.android.database.sqlite.SQLiteDatabase;
114-
import io.requery.android.database.sqlite.SQLiteDatabaseConfiguration;
115-
import java.util.Collections;
116-
117-
...
118-
119-
private void jsExtension() {
120-
try {
121-
SQLiteCustomExtension jsExtension = new SQLiteCustomExtension(getApplicationInfo().nativeLibraryDir + "/js", null);
122-
SQLiteDatabaseConfiguration config = new SQLiteDatabaseConfiguration(
123-
getCacheDir().getPath() + "/js_test.db",
124-
SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.OPEN_READWRITE,
125-
Collections.emptyList(),
126-
Collections.emptyList(),
127-
Collections.singletonList(jsExtension)
128-
);
129-
130-
SQLiteDatabase db = SQLiteDatabase.openDatabase(config, null, null);
131-
132-
Cursor cursor = db.rawQuery("SELECT js_version()", null);
133-
if (cursor.moveToFirst()) {
134-
String version = cursor.getString(0);
135-
Log.i("sqlite-js", "js_version(): " + version);
136-
}
137-
cursor.close();
138-
db.close();
139-
140-
} catch (Exception e) {
141-
Log.e("sqlite-js", "Error: " + e.getMessage());
142-
}
143-
}
76+
SQLiteCustomExtension jsExtension = new SQLiteCustomExtension(getApplicationInfo().nativeLibraryDir + "/js", null);
77+
SQLiteDatabaseConfiguration config = new SQLiteDatabaseConfiguration(
78+
getCacheDir().getPath() + "/js_test.db",
79+
SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.OPEN_READWRITE,
80+
Collections.emptyList(),
81+
Collections.emptyList(),
82+
Collections.singletonList(jsExtension)
83+
);
84+
SQLiteDatabase db = SQLiteDatabase.openDatabase(config, null, null);
14485
```
14586

87+
**Note:** Additional settings and configuration are required for a complete setup. For full implementation details, see the [complete Android example](https://github.com/sqliteai/sqlite-extensions-guide/blob/main/examples/android/README.md).
88+
14689
## Functions Overview
14790

14891
SQLite-JS provides several ways to extend SQLite functionality with JavaScript:

0 commit comments

Comments
 (0)