-
Notifications
You must be signed in to change notification settings - Fork 77
Home
- Below is a QuickStart guide
- See README document for further useage
-
'core' - holding the actual library code for you to use
-
'acceptance' - this is an Android acceptance test project with tests related to the core
-
'demo' - an Android project showing a demonstration of the various uses of the core library
1 ) Create an SQL file and place it in YourAndroidApp/assets/migrations
2 ) Pre-pend this SQL file with a version number (this will be your database version number)
1_My_Setup_File.sql
CREATE TABLE 'shop' (_id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, postcode TEXT);
INSERT INTO 'shop' (name, postcode) VALUES ("TheBigBang Shop", "L300RA");
3 ) to update the database create a new file and increment your version number
2_My_Database_Changes.sql
UPDATE shop SET postcode="N17BJ" WHERE name='TheBigBang Shop';
Alternatively if you don't create an SQL file you can create your database programatically with the normal Android librarys ( n.b. this is what the SQLiteProvider library is doing for you automagically.
1 ) Create a content provider that extends novoda.lib.sqliteprovider.provider.SQLiteContentProviderImpl
2 ) Add an authority to that provider
import novoda.lib.sqliteprovider.provider.SQLiteContentProviderImpl;
public class FireworkProvider extends SQLiteContentProviderImpl {
public static final String AUTHORITY = "content://com.novoda.demo/";
}
3 ) Register your provider with the Android System in your AndroidManifest
<provider
android:name="com.novoda.sqliteprovider.demo.provider.FireworkProvider"
android:authorities="com.novoda.demo"
android:exported="false" />
-
Use the content provider with a URI to query your database
Context.getContentResolver().query(Uri.parse("content://com.novoda.demo/fireworks/1"));
The above would return you a Cursor pointing to the row in the fireworks table with the primary key of 1
There are also core unit tests you may find useful
The status of the build can be seen here: SQLiteProvider on Jenkins
The Sonar build health (static code analysis) can be seen here: SQLiteProvider on Sonar
<dependency>
<groupId>com.novoda</groupId>
<artifactId>sqliteprovider-core</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
- TODO
- Android SQLiteProvider Library Project is licensed under Apache 2