Skip to content

Commit cfe48d9

Browse files
committed
update docs
1 parent b8eec46 commit cfe48d9

File tree

1 file changed

+52
-15
lines changed

1 file changed

+52
-15
lines changed

README.markdown

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,42 @@ It is implemented as an extension to `SQLiteOpenHelper`, providing an efficient
99

1010
Rather than implementing `onCreate()` and `onUpgrade()` methods to execute a bunch of SQL statements, developers simply include appropriately named file assets in their project's `assets` directory. These will include the initial SQLite database file for creation and optionally any SQL upgrade scripts.
1111

12+
Setup
13+
-----
14+
15+
#### Gradle
16+
17+
If you are using the Gradle build system, simply add the following dependency in your `build.gradle` file:
18+
19+
```groovy
20+
dependencies {
21+
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
22+
}
23+
```
24+
25+
#### Ant/Eclipse
26+
27+
If you are using the old build system, download and place the latest library [JAR][1] inside your project's `libs` folder.
28+
29+
1230
Usage
1331
-----
1432

1533
Copy [android-sqlite-asset-helper.jar](https://github.com/jgilfelt/android-sqlite-asset-helper/blob/master/lib/android-sqlite-asset-helper.jar?raw=true) into your Android project's `libs` directory and add it to the build path.
1634

1735
Extend `SQLiteAssetHelper` as you would normally do `SQLiteOpenHelper`, providing the constructor with a database name and version number:
1836

19-
public class MyDatabase extends SQLiteAssetHelper {
20-
21-
private static final String DATABASE_NAME = "northwind";
22-
private static final int DATABASE_VERSION = 1;
23-
24-
public MyDatabase(Context context) {
25-
super(context, DATABASE_NAME, null, DATABASE_VERSION);
26-
}
27-
}
37+
```java
38+
public class MyDatabase extends SQLiteAssetHelper {
2839

40+
private static final String DATABASE_NAME = "northwind";
41+
private static final int DATABASE_VERSION = 1;
42+
43+
public MyDatabase(Context context) {
44+
super(context, DATABASE_NAME, null, DATABASE_VERSION);
45+
}
46+
}
47+
```
2948

3049
The name of the database must match a zip compressed file placed in your project's `assets/databases` directory. This zip file must contain a single SQLite database file. For example:
3150

@@ -41,7 +60,7 @@ The database is made available for use the first time either `getReadableDatabas
4160

4261
The class will throw a `SQLiteAssetHelperException` if you do not provide the appropriately named file.
4362

44-
The [samples:v1](https://github.com/jgilfelt/android-sqlite-asset-helper/tree/master/samples/v1) project demonstrates a simple database creation and usage example using the classic Northwind database.
63+
The [samples:database-v1](https://github.com/jgilfelt/android-sqlite-asset-helper/tree/v2/samples/database-v1) project demonstrates a simple database creation and usage example using the classic Northwind database.
4564

4665
Database Upgrades
4766
-----------------
@@ -56,11 +75,11 @@ Update the initial SQLite database in the project's `assets/databases` directory
5675

5776
assets/databases/<database_name>_upgrade_<from_version>-<to_version>.sql
5877

59-
For example, [assets/databases/northwind_upgrade_1-2.sql](https://github.com/jgilfelt/android-sqlite-asset-helper/blob/master/samples/v2/assets/databases/northwind_upgrade_1-2.sql) upgrades the database named "northwind" from version 1 to 2. You can include multiple upgrade files to upgrade between any two given versions.
78+
For example, [assets/databases/northwind.db_upgrade_1-2.sql](https://github.com/jgilfelt/android-sqlite-asset-helper/blob/v2/samples/database-v2-upgrade/assets/databases/northwind.db_upgrade_1-2.sql) upgrades the database named "northwind" from version 1 to 2. You can include multiple upgrade files to upgrade between any two given versions.
6079

6180
If there are no files to form an upgrade path from a previously installed version to the current one, the class will throw a `SQLiteAssetHelperException`.
6281

63-
The [samples:v2](https://github.com/jgilfelt/android-sqlite-asset-helper/tree/master/example-v2) project demonstrates a simple upgrade to the Northwind database which adds a FullName column to the Employee table.
82+
The [samples:database-v2-upgrade](https://github.com/jgilfelt/android-sqlite-asset-helper/tree/v2/samples/database-v2-upgrade) project demonstrates a simple upgrade to the Northwind database which adds a FullName column to the Employee table.
6483

6584
### Generating upgrade scripts
6685

@@ -81,7 +100,25 @@ Credits
81100

82101
* [Alexandros Schillings](https://github.com/alt236)
83102
* [Cyril Mottier](https://github.com/cyrilmottier)
103+
* [Jon Adams](https://github.com/jon-adams)
104+
* [Kevin](https://github.com/kevinchai)
105+
106+
License
107+
-------
108+
109+
Copyright (C) 2011 readyState Software Ltd
110+
Copyright (C) 2007 The Android Open Source Project
111+
112+
Licensed under the Apache License, Version 2.0 (the "License");
113+
you may not use this file except in compliance with the License.
114+
You may obtain a copy of the License at
115+
116+
http://www.apache.org/licenses/LICENSE-2.0
117+
118+
Unless required by applicable law or agreed to in writing, software
119+
distributed under the License is distributed on an "AS IS" BASIS,
120+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121+
See the License for the specific language governing permissions and
122+
limitations under the License.
84123

85-
The code in this project is licensed under the Apache Software License 2.0.
86-
<br />
87-
Copyright (c) 2011 readyState Software Ltd.
124+
[1]: http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.readystatesoftware.sqliteasset&a=sqliteassethelper&v=LATEST&c=jar

0 commit comments

Comments
 (0)