Skip to content

Commit f4a37c7

Browse files
committed
update docs
1 parent 0c2a5f1 commit f4a37c7

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

README.markdown

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ dependencies {
2424

2525
#### Ant/Eclipse
2626

27-
If you are using the old build system, download and place the latest library [JAR][1] inside your project's `libs` folder.
27+
If you are using the old build system, download the latest library [JAR][1] and put it in your project's `libs` folder.
2828

2929
Usage
3030
-----
3131

32+
SQLiteAssetHelper is intended as a drop in alternative for the framework's [SQLiteOpenHelper](https://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html). Please familiarize yourself with the behaviour and lifecycle of that class.
33+
3234
Extend `SQLiteAssetHelper` as you would normally do `SQLiteOpenHelper`, providing the constructor with a database name and version number:
3335

3436
```java
@@ -43,11 +45,19 @@ public class MyDatabase extends SQLiteAssetHelper {
4345
}
4446
```
4547

46-
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:
48+
SQLiteAssetHelper relies upon asset file and folder naming conventions. At minimum, you must provide the following in your `assets` directory, which will either be in your project root directory or under `src/main` in the gradle project structure:
49+
50+
* A `databases` subdirectory inside `assets`
51+
* A SQLite database inside the `databases` subdirectory whose file name matches the database name you provide in code (including the file extension, if any)
52+
53+
For the example above, ther project would contain the following:
54+
55+
`src/main/assets/databases/northwind.db`
4756

48-
assets/databases/northwind.zip
57+
Earlier versions of this library required the database asset to be compressed within a ZIP archive. This is no longer required, but is still supported. Applications still targeting Gingerbread or lower should continue to provide a compressed archive to ensure large database files are not corrupted during the packaging process. The more Linux friendly GZIP format is also supported. The naming conventions using the above example are as follows:
4958

50-
The SQLite database file must be the only file within the zip archive. The database file itself can be named anything you like. ZIP compression is used to minimize APK file size while ensuring that aapt (part of the Android build process) does not corrupt large database files during its own compression process.
59+
* ZIP: `src/main/assets/databases/northwind.db.zip` (a single SQLite database file must be the only file within the archive)
60+
* GZIP: `src/main/assets/databases/northwind.db.gz`
5161

5262
The database will be extracted from the assets and copied into place within your application's private data directory. If you prefer to store the database file somewhere else (such as external storage) you can use the alternate constructor to specify a storage path. You must ensure that this path is available and writable whenever your application needs to access the database.
5363

0 commit comments

Comments
 (0)