Skip to content

react-native-async-storage/sqlite-storage-native

Repository files navigation

Async Storage SQLite

Multiplatform key-value storage backed by SQLite for React Native Async Storage

version badge

Installation

Android

implementation("io.github.react-native-async-storage:async-storage-sqlite:VERSION")

iOS (CocoaPods)

pod 'AsyncStorageSQLiteKMP', 'VERSION'

Quick start

Visit Usage page to learn more

Android

import org.asyncstorage.sqlitestorage.SQLiteStorageFactory

val storage = SQLiteStorageFactory(this).create("my_database_name")

suspend fun single(): Entry {
  val entry = storage.read("my_key")
  return entry
}

suspend fun singleWrite() {
  val entry = Entry("my_key", "my_value")
  storage.write(entry)
}

iOS

import AsyncStorageSQLite

let storage = AsyncStorageSQLite("my_database_name")

func single() async throws -> Entry {
    let entry = try await storage.read(key: "my_key")
    return entry
}

func singleWrite() async throws {
    let entry = Entry(key: "my_key", value: "my_value")
    try await storage.write(entry: entry)
}

Contributing

Tests

Gradle tasks to run tests:

storageTests - run unit tests for all platforms

storageTestsAndroid - run unit tests for Android platform

storageTestsIos - run unit tests for iOS platform

Re-running tests when tasks are up-to-date:

./gradlew :sqlite-storage:storageTests --rerun-tasks

Website

  1. Make sure Python 3 (v3.11.7+) and pip (v24.0+) is installed
  2. Follow installation steps from MkDocs Material
  3. Run development docs:
mkdocs serve