Skip to content

Commit c53c7d6

Browse files
gvanderclayandpor
authored andcommitted
Add documentation for using android-native platform (#393)
1 parent 4c7b211 commit c53c7d6

File tree

1 file changed

+41
-15
lines changed

1 file changed

+41
-15
lines changed

README.md

+41-15
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,24 @@ The library has been tested with React 16.2 (and earlier) and XCode 7,8,9 - it w
1818

1919
Version 3.2 is the first version compatible with RN 0.40.
2020

21+
# Installation
22+
```
23+
npm install --save react-native-sqlite-storage
24+
```
25+
Then follow the instructions for your platform to link react-native-sqlite-storage into your project
2126

22-
# How to use (iOS):
27+
## iOS
28+
#### Standard Method
29+
** React Native 0.60 and above **
30+
Run `cd ios && pod install && cd ..`. Linking is not required in React Native 0.60 and above
31+
32+
** React Native 0.59 and below **
2333

2434
#### Step 1. Install Dependencies
2535

2636
##### With CocoaPods:
2737

28-
This command should be executed in the root directory of your RN project
29-
```shell
30-
npm install --save react-native-sqlite-storage
31-
```
32-
Then add this to your Podfile which should be located inside the ios project subdirectory
38+
Add this to your Podfile which should be located inside the ios project subdirectory
3339
```ruby
3440
pod 'React', :path => '../node_modules/react-native'
3541
pod 'react-native-sqlite-storage', :path => '../node_modules/react-native-sqlite-storage'
@@ -45,14 +51,12 @@ OR
4551
pod update
4652
```
4753

48-
4954
Done, skip to Step 2.
5055

5156
##### Without CocoaPods:
5257

5358
This command should be executed in the root directory of your RN project
5459
```shell
55-
npm install --save react-native-sqlite-storage
5660
react-native link
5761
```
5862

@@ -126,12 +130,34 @@ db.transaction((tx) => {
126130

127131
# How to use (Android):
128132

129-
#### Step 1 - NPM Install
133+
** React Native 0.60 and above **
134+
If you would like to use the devices SQLite there are no extra steps.
135+
However, if you would like to use the SQLite bundled with this library (includes support for FTS5), add the following to your `react-native.config.js`
130136

131-
```shell
132-
npm install --save react-native-sqlite-storage
137+
```js
138+
module.exports = {
139+
...,
140+
dependencies: {
141+
...,
142+
"react-native-sqlite-storage": {
143+
platforms: {
144+
android: {
145+
sourceDir:
146+
"../node_modules/react-native-sqlite-storage/platforms/android-native",
147+
packageImportPath: "import io.liteglue.SQLitePluginPackage;",
148+
packageInstance: "new SQLitePluginPackage()"
149+
}
150+
}
151+
}
152+
...
153+
}
154+
...
155+
};
133156
```
134-
#### Step 2 - Update Gradle Settings (located under Gradle Settings in Project Panel)
157+
158+
** React Native 0.59 and below **
159+
160+
#### Step 1 - Update Gradle Settings (located under Gradle Settings in Project Panel)
135161

136162
```gradle
137163
// file: android/settings.gradle
@@ -141,7 +167,7 @@ include ':react-native-sqlite-storage'
141167
project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/src/android')
142168
```
143169

144-
#### Step 3 - Update app module Gradle Build script (located under Gradle Settings in Project Panel)
170+
#### Step 2 - Update app module Gradle Build script (located under Gradle Settings in Project Panel)
145171

146172
```gradle
147173
// file: android/app/build.gradle
@@ -153,7 +179,7 @@ dependencies {
153179
}
154180
```
155181

156-
#### Step 4 - Register React Package (this should work on React version but if it does not , try the ReactActivity based approach. Note: for version 3.0.0 and below you would have to pass in the instance of your Activity to the SQLitePluginPackage constructor
182+
#### Step 3 - Register React Package (this should work on React version but if it does not , try the ReactActivity based approach. Note: for version 3.0.0 and below you would have to pass in the instance of your Activity to the SQLitePluginPackage constructor
157183

158184
```java
159185
...
@@ -205,7 +231,7 @@ public class MainApplication extends Application implements ReactApplication {
205231
}
206232
```
207233

208-
#### Step 5 - Require and use in Javascript - see full examples (callbacks and Promise) in test directory.
234+
#### Step 4 - Require and use in Javascript - see full examples (callbacks and Promise) in test directory.
209235

210236
```js
211237
// file: index.android.js

0 commit comments

Comments
 (0)