Skip to content

Commit 56b5b95

Browse files
committed
docs: compact Android package section
1 parent a72b4bb commit 56b5b95

File tree

1 file changed

+13
-72
lines changed

1 file changed

+13
-72
lines changed

README.md

Lines changed: 13 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -81,86 +81,27 @@ sqlite3_close(db)
8181

8282
### Android Package
8383

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

86-
**Groovy:**
8786
```gradle
88-
repositories {
89-
google()
90-
mavenCentral()
91-
maven { url 'https://jitpack.io' }
92-
}
93-
94-
dependencies {
95-
// ...
96-
97-
// Use requery's SQLite instead of Android's built-in SQLite to support loading custom extensions
98-
implementation 'com.github.requery:sqlite-android:3.49.0'
99-
// Both packages below are identical - use either one
100-
implementation 'ai.sqlite:vector:0.9.32' // Maven Central
101-
// implementation 'com.github.sqliteai:sqlite-vector:0.9.32' // JitPack (alternative)
102-
}
87+
implementation 'ai.sqlite:vector:0.9.34'
10388
```
10489

105-
**Kotlin:**
106-
```kotlin
107-
repositories {
108-
google()
109-
mavenCentral()
110-
maven(url = "https://jitpack.io")
111-
}
112-
113-
dependencies {
114-
// ...
115-
116-
// Use requery's SQLite instead of Android's built-in SQLite to support loading custom extensions
117-
implementation("com.github.requery:sqlite-android:3.49.0")
118-
// Both packages below are identical - use either one
119-
implementation("ai.sqlite:vector:0.9.32") // Maven Central
120-
// implementation("com.github.sqliteai:sqlite-vector:0.9.32") // JitPack (alternative)
121-
}
122-
```
123-
124-
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).
125-
12690
Here's an example of how to use the package:
12791
```java
128-
import android.database.Cursor;
129-
import android.util.Log;
130-
import io.requery.android.database.sqlite.SQLiteCustomExtension;
131-
import io.requery.android.database.sqlite.SQLiteDatabase;
132-
import io.requery.android.database.sqlite.SQLiteDatabaseConfiguration;
133-
import java.util.Collections;
134-
135-
...
136-
137-
private void vectorExtension() {
138-
try {
139-
SQLiteCustomExtension vectorExtension = new SQLiteCustomExtension(getApplicationInfo().nativeLibraryDir + "/vector", null);
140-
SQLiteDatabaseConfiguration config = new SQLiteDatabaseConfiguration(
141-
getCacheDir().getPath() + "/vector_test.db",
142-
SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.OPEN_READWRITE,
143-
Collections.emptyList(),
144-
Collections.emptyList(),
145-
Collections.singletonList(vectorExtension)
146-
);
147-
148-
SQLiteDatabase db = SQLiteDatabase.openDatabase(config, null, null);
149-
150-
Cursor cursor = db.rawQuery("SELECT vector_version()", null);
151-
if (cursor.moveToFirst()) {
152-
String version = cursor.getString(0);
153-
Log.i("sqlite-vector", "vector_version(): " + version);
154-
}
155-
cursor.close();
156-
db.close();
157-
158-
} catch (Exception e) {
159-
Log.e("sqlite-vector", "Error: " + e.getMessage());
160-
}
161-
}
92+
SQLiteCustomExtension vectorExtension = new SQLiteCustomExtension(getApplicationInfo().nativeLibraryDir + "/vector", null);
93+
SQLiteDatabaseConfiguration config = new SQLiteDatabaseConfiguration(
94+
getCacheDir().getPath() + "/vector_test.db",
95+
SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.OPEN_READWRITE,
96+
Collections.emptyList(),
97+
Collections.emptyList(),
98+
Collections.singletonList(vectorExtension)
99+
);
100+
SQLiteDatabase db = SQLiteDatabase.openDatabase(config, null, null);
162101
```
163102

103+
**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).
104+
164105
### Python Package
165106

166107
Python developers can quickly get started using the ready-to-use `sqlite-vector` package available on PyPI:

0 commit comments

Comments
 (0)