npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-android-sqlite

v0.1.6

Published

A react native android wrapper for SQLite

Downloads

42

Readme

React Native Android Sqlite

A react native android wrapper for SQLite

Rationale

React Native doesn't have a built-in module to access Sqlite databases, either in iOS or Android.

This library intends to fill the gap on the Android side.

Setup

  • Install Module
npm install --save-dev react-native-android-sqlite
  • android/settings.gradle
...
include ':react-native-android-sqlite'
project(':react-native-android-sqlite').projectDir = new File(settingsDir, '../node_modules/react-native-android-sqlite')
  • android/app/build.gradle
dependencies {
	...
	compile project(':react-native-android-sqlite')
}
  • register module (in MainActivity.java)
...

import io.jbrodriguez.react.*; // <--- import 

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
	...
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mReactRootView = new ReactRootView(this);

        mReactInstanceManager = ReactInstanceManager.builder()
                .setApplication(getApplication())
                .setBundleAssetName("index.android.bundle")
                .setJSMainModuleName("index.android")
                .addPackage(new MainReactPackage())
                .addPackage(new RNSQLiteModule())           // <- add here
                .setUseDeveloperSupport(BuildConfig.DEBUG)
                .setInitialLifecycleState(LifecycleState.RESUMED)
                .build();

        mReactRootView.startReactApplication(mReactInstanceManager, "YourProject", null);

        setContentView(mReactRootView);
    }	
}

Usage

This library depends on SQLiteAssetHelper.

The idea is that you import your previously created database as an application asset.

SQLiteAssetHelper manages schema definition (create), as well as upgrades.

For more information refer to SQLiteAssetHelper's docs and/or check SQLiteOpenHelper

So, the first step involves copying your sqlite db to the following folder

<YourProject>/android/app/src/main/assets/databases

Substitute <YourProject> with the folder where your app resides, i.e. AwesomeProject.

NOTE: Originally, I suggested copying the sqlite db to <ReactNativeRootFolder>/node_modules/react-native-android-sqlite/src/main/assets/databases. Although it works, the db will be erased each time you upgrade this component, so it's better to follow the updated instructions.

Having done that, you can start interacting with the db, through 4 public functions:

  • init
  • query
  • exec
  • close

Init

The database must be initialized before any other call takes place

var sqlite = require('react-native-android-sqlite')

var databaseName = 'app.db'

sqlite.init(databaseName)
	.then((_) => {
		console.log('database initialized.')
	}
)

Exec

pre-requisite: the db must have been initialized

var sqlite = require('react-native-android-sqlite')

var sql = 'INSERT INTO todo(name, completed) VALUES (?, ?)'
var params = ["Create react native android sqlite", 1]

sqlite.exec(sql, params)
	.then((_) => {
		console.log('row inserted.')
	}
)

Query

pre-requisite: the db must have been initialized

var sqlite = require('react-native-android-sqlite')

var sql = 'SELECT * FROM todo WHERE completed = ?'
var params = [1]

sqlite.query(sql, params)
	.then((data) => {
		console.log('retrieved: ', data)
	}
)

Close

pre-requisite: the db must have been initialized

sqlite.close()
    .then((_) => {
        console.log('database closed')
    }
)

Known Issues

  • It doesn't return the id for a newly inserted row (maybe create a separate insert function ?)
  • Column types currently supported are Integer and String
  • Additional error handling should be implemented
  • Although I'm using it in my personal projects, it's still an early release. Please do read the license

Changes

Please submit any PR's you seem fit.

Credits

LICENSE

MIT