Skip to content
This repository was archived by the owner on Feb 11, 2022. It is now read-only.

Commit 438617d

Browse files
committed
Merge pull request #42 from novoda/new_readme_structure
Renames the project and uses the new readme structure
2 parents 169e5d0 + 524fd4b commit 438617d

2 files changed

Lines changed: 28 additions & 197 deletions

File tree

README.md

Lines changed: 25 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -1,215 +1,46 @@
1-
SQLiteProvider [![](http://ci.novoda.com/buildStatus/icon?job=SQLiteProvider)](http://ci.novoda.com/job/SQLiteProvider/lastSuccessfulBuild/console)
2-
================================================
1+
# sqlite-provider [![](http://ci.novoda.com/buildStatus/icon?job=sqlite-provider)](http://ci.novoda.com/job/sqlite-provider/lastSuccessfulBuild/console) [![](https://raw.githubusercontent.com/novoda/novoda/master/assets/btn_apache_lisence.png)](LICENSE.txt)
32

4-
A simplification of database access.
3+
A simplification of database access for Android.
54

6-
SQLiteProvider implements a ContentProvider for you that allows database access using [Uri][1]'s
75

8-
Download
9-
--------
6+
## Description
107

11-
Add it to your projects via Gradle or Maven:
8+
sqlite-provider implements a ContentProvider for you that allows database access using [Uri][1]s
9+
The library is meant to augment the ContentProvider interface to fit SQLite in a more pronounced way. The aim is to set convention on queries via Uris.
1210

13-
Gradle:
14-
````groovy
15-
dependencies {
16-
compile 'com.novoda:sqliteprovider-core:1.0.3'
17-
}
18-
````
19-
Maven:
20-
````xml
21-
<dependency>
22-
<groupId>com.novoda</groupId>
23-
<artifactId>sqliteprovider-core</artifactId>
24-
<version>1.0.3</version>
25-
</dependency>
26-
````
27-
28-
You just need to declare jCenter in the list of repositories:
29-
30-
Gradle:
31-
````groovy
32-
repositories {
33-
jcenter()
34-
}
35-
````
36-
Maven:
37-
````xml
38-
<repositories>
39-
<repository>
40-
<id>bintray-jcenter</id>
41-
<url>http://jcenter.bintray.com</url>
42-
</repository>
43-
</repositories>
44-
````
45-
46-
Check the [WIKI][5] for further instruction
47-
48-
[ ![Download](https://api.bintray.com/packages/novoda/maven/sqliteprovider-core/images/download.svg) ](https://bintray.com/novoda/maven/sqliteprovider-core/_latestVersion)
49-
50-
Usage
51-
--------
52-
53-
Simple example source code can be found in this demo module: [Android Simple Demo][3]
54-
55-
Advanced queries & source code can be found in this demo module: [Android Extended Demo][4]
56-
57-
58-
Overview
59-
--------
60-
61-
The library is meant to augment the ContentProvider interface to fit SQLite in a more pronounced way. The aim is
62-
to set convention on queries via URI.
63-
64-
The following Uris are possible (some may not be supported yet):
65-
66-
### General Uri by convention
67-
68-
Generic table support:
69-
70-
Uri: content://<authority>/tableName
71-
Sql: select * from "tableName"
72-
73-
Primary key support:
74-
75-
Uri: content://<authority>/tableName/1
76-
Sql: select * from "tableName" where _id=1
77-
78-
One to many support:
79-
80-
Uri: content://<authority>/tableName/1/child
81-
Sql: select * from "child" where tableName_id=1
82-
83-
Group by & having support:
84-
85-
Uri: content://<authority>/tableName?groupBy=col&having=value
86-
Sql: select * from tableName group by col having value
87-
88-
limit support:
89-
90-
Uri: content://<authority>/tableName?limit=number
91-
Sql: select * from tableName limit number
92-
93-
distinct support:
94-
95-
Uri: content://<authority>/tableName?distinct=true
96-
Sql: select distinct * from tableName limit number
97-
98-
join support (TODO):
99-
100-
Uri: content://<authority>/parent/1/child/2
101-
Sql: select * from child inner join parent on parent._id=child.parent_id;
102-
103-
104-
### Info Uri
105-
106-
Gives the ability to query information from the table SQLITE_MASTER and versionning.
107-
108-
content://<authority>/_info
109-
110-
Querying the above will yield the following cursor:
111-
112-
type TEXT | name TEXT | tbl_name TEXT | rootpage INTEGER | sql TEXT
113-
114-
If you are interested to only get the table name, the following should be helpful:
11511

116-
getContentResolver().query(Uri.parse("content://<authority>/_info"), new String[] {"name"}, null, null, null);
117-
118-
119-
To get the current version of the database similar to "select sqlite_version() AS sqlite_version":
12+
## Adding to your project
12013

121-
content://<authority>/_info?version
122-
123-
returns the following cursor:
14+
To start using this library, add these lines to the `build.gradle` of your project:
12415

125-
sqlite_version TEXT
126-
127-
### Size management
128-
129-
Executing some file resizing using vacuum
130-
131-
content://<authority>/_vacuum
132-
133-
(TODO) set max size??
134-
135-
### Pragma Uris
136-
137-
138-
Ability to execute Pragma calls against SQLite. This is handy to get further info on table or set values such as "PRAGMA synchronous=OFF"
139-
140-
content://<authority>/_pragma?<pragma_name>=<value>
141-
142-
For instance the following will exectute "PRAGMA synchronous=OFF"
143-
144-
content://<authority>/_pragma?synchronous=OFF
145-
146-
The following will give back table information for a specific table:
147-
148-
content://<authority>/_pragma?table_info("tableName")
149-
150-
The resulting cursor is
151-
152-
column name | data type | can be NULL? | the default value for the column
153-
154-
155-
### Table creation
156-
157-
If you insert against
158-
159-
content://<authority>/_db?create=<tableName>&withId=<true|false>&foreignKey=[<comma_separated_list_of_parent_tables>]&createdAt=false&updatedAt=false
160-
161-
(TODO) alter?
162-
163-
```
164-
tableName (mandatory): the table name
165-
withId (optional): automatically add "_id PRIMARY KEY AUTOINCREMENT" - default is true
166-
foreignKey (optional): automatically add <fk_name>_id as foreign key to table creation
167-
createdAt (optional): will put a createdAt field which contains creation date - default to insert
168-
updatedAt (optional): will put a updatedAt field which contains update date - default to insert
169-
```
170-
171-
you should have content values put with "column name" mapped to a SQLite type (look at SQLiteType)
16+
```groovy
17+
repositories {
18+
jcenter()
19+
}
17220
173-
```java
174-
Uri uri = Uri.parse("content://authority/_db?create=table");
175-
ContentValues values = new ContentValues();
176-
values.put("name", "TEXT");
177-
values.put("rid", "INTEGER");
178-
getContentResolver().insert(uri, values);
21+
dependencies {
22+
compile 'com.novoda:sqlite-provider:1.0.3'
23+
}
17924
```
18025

181-
Build
182-
-----
183-
184-
To build the core library jar you can use the following gradle command;
185-
186-
./gradlew assembleRelease
187-
188-
This will result in the core jar being available at
18926

190-
core/build/bundles/release/classes.jar
27+
## Simple usage
19128

29+
Simple example source code can be found in this demo module: [Android Simple Demo][2]
19230

193-
License
194-
-------
31+
Advanced queries & source code can be found in this demo module: [Android Extended Demo][3]
19532

196-
(c) Copyright 2014 Novoda
19733

198-
Licensed under the Apache License, Version 2.0 (the "License");
199-
you may not use this file except in compliance with the License.
200-
You may obtain a copy of the License at
34+
## Links
20135

202-
http://www.apache.org/licenses/LICENSE-2.0
36+
Here are a list of useful links:
20337

204-
Unless required by applicable law or agreed to in writing, software
205-
distributed under the License is distributed on an "AS IS" BASIS,
206-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
207-
See the License for the specific language governing permissions and
208-
limitations under the License.
38+
* We always welcome people to contribute new features or bug fixes, [here is how](https://github.com/novoda/novoda/blob/master/CONTRIBUTING.md)
39+
* If you have a problem check the [Issues Page](https://github.com/novoda/sqlite-provider/issues) first to see if we are working on it
40+
* For further usage or to delve more deeply checkout the [Project Wiki](https://github.com/novoda/sqlite-provider/wiki)
41+
* Looking for community help, browse the already asked [Stack Overflow Questions](http://stackoverflow.com/questions/tagged/support-sqlite-provider) or use the tag: `support-sqlite-provider` when posting a new question
20942

21043

21144
[1]: http://developer.android.com/reference/android/net/Uri.html
212-
[2]: https://github.com/novoda/public-mvn-repo/raw/master/releases/com/novoda/sqliteprovider-core/1.0.1/sqliteprovider-core-1.0.1.jar
213-
[3]: https://github.com/novoda/SQLiteProvider/tree/master/demo-simple
214-
[4]: https://github.com/novoda/SQLiteProvider/tree/master/demo-extended
215-
[5]: https://github.com/novoda/SQLiteProvider/wiki
45+
[2]: https://github.com/novoda/SQLiteProvider/tree/master/demo-simple
46+
[3]: https://github.com/novoda/SQLiteProvider/tree/master/demo-extended

core/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ android {
2424
publish {
2525
userOrg = 'novoda'
2626
groupId = 'com.novoda'
27-
artifactId = 'sqliteprovider-core'
28-
version = '1.0.5-SNAPSHOT'
27+
artifactId = 'sqlite-provider'
28+
version = '1.0.5'
2929
description = 'Extended SQLite functionality for Android'
30-
website = 'https://github.com/novoda/SQLiteProvider'
30+
website = 'https://github.com/novoda/sqlite-provider'
3131
}

0 commit comments

Comments
 (0)