Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jgilfelt committed Jan 16, 2014
2 parents b9b64a3 + dc7efb5 commit 0fa4696
Show file tree
Hide file tree
Showing 46 changed files with 383 additions and 304 deletions.
47 changes: 34 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
*.DS_Store
core/local.properties
core/bin/
core/gen/
example-v1/local.properties
example-v1/bin/
example-v1/gen/
example-v2/local.properties
example-v2/bin/
example-v2/gen/
example-v3/local.properties
example-v3/bin/
example-v3/gen/
# Eclipse
.project
.classpath
.settings
.checkstyle

# IntelliJ IDEA
.idea
*.iml
*.ipr
*.iws
classes
gen-external-apklibs

# Gradle
.gradle
build

# Maven
target
release.properties
pom.xml.*

# Ant
bin
gen
build.xml
ant.properties
local.properties
proguard.cfg
proguard-project.txt

# Other
.DS_Store
19 changes: 12 additions & 7 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The name of the database must match a zip compressed file placed in your project

assets/databases/northwind.zip

The SQLite database file must be the only file within the zip archive. The databse 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.
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.

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.

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

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

The [example-v1](https://github.com/jgilfelt/android-sqlite-asset-helper/tree/master/example-v1) project demonstrates a simple database creation and usage example using the classic Northwind database.
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.

Database Upgrades
-----------------
Expand All @@ -56,26 +56,31 @@ Update the initial SQLite database in the project's `assets/databases` directory

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

For example, [assets/databases/northwind_upgrade_1-2.sql](https://github.com/jgilfelt/android-sqlite-asset-helper/blob/master/example-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.
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.

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`.

The [example-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.
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.

### Generating upgrade scripts

You can use 3rd party tools to automatically generate the SQL required to modify a database from one schema version to another. One such application is [SQLite Compare Utility](http://www.codeproject.com/KB/database/SQLiteCompareUtility.aspx) for Windows.

### Forcing upgrades

You can force users onto the latest version of the SQLite database (overwriting the local database with the one in the assets) by calling the `setForcedUpgradeVersion(int version)` method in your constructor. The argument passed is the the version number below which the upgrade will be forced. Note that this will forcibly overwriting any existing local database and all data within it.
You can force users onto the latest version of the SQLite database (overwriting the local database with the one in the assets) by calling the `setForcedUpgradeVersion(int version)` method in your constructor. The argument passed is the version number below which the upgrade will be forced. Note that this will forcibly overwriting any existing local database and all data within it.

Credits
-------

Author: [Jeff Gilfelt](https://github.com/jgilfelt)
####Author:

Contributor: [Alexandros Schillings](https://github.com/alt236)
* [Jeff Gilfelt](https://github.com/jgilfelt)

#### Contributors:

* [Alexandros Schillings](https://github.com/alt236)
* [Cyril Mottier](https://github.com/cyrilmottier)

The code in this project is licensed under the Apache Software License 2.0.
<br />
Expand Down
13 changes: 13 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:0.6.+"
}
}

task wrapper(type: Wrapper) {
gradleVersion = '1.8'
}
9 changes: 0 additions & 9 deletions core/.classpath

This file was deleted.

33 changes: 0 additions & 33 deletions core/.project

This file was deleted.

3 changes: 0 additions & 3 deletions core/lint.xml

This file was deleted.

40 changes: 0 additions & 40 deletions core/proguard.cfg

This file was deleted.

11 changes: 0 additions & 11 deletions core/project.properties

This file was deleted.

10 changes: 0 additions & 10 deletions example-v1/.classpath

This file was deleted.

33 changes: 0 additions & 33 deletions example-v1/.project

This file was deleted.

Binary file removed example-v1/libs/android-sqlite-asset-helper.jar
Binary file not shown.
40 changes: 0 additions & 40 deletions example-v1/proguard.cfg

This file was deleted.

11 changes: 0 additions & 11 deletions example-v1/project.properties

This file was deleted.

10 changes: 0 additions & 10 deletions example-v2/.classpath

This file was deleted.

33 changes: 0 additions & 33 deletions example-v2/.project

This file was deleted.

Binary file removed example-v2/libs/android-sqlite-asset-helper.jar
Binary file not shown.
Loading

0 comments on commit 0fa4696

Please sign in to comment.