| 1 |
efrain |
1 |
package com.cesams.twogetskills.sync;
|
|
|
2 |
|
|
|
3 |
import android.content.ContentProvider;
|
|
|
4 |
import android.content.ContentResolver;
|
|
|
5 |
import android.content.ContentValues;
|
|
|
6 |
import android.content.UriMatcher;
|
|
|
7 |
import android.database.Cursor;
|
|
|
8 |
import android.net.Uri;
|
|
|
9 |
|
|
|
10 |
import com.cesams.twogetskills.Constants;
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
public class SyncContentProvider extends ContentProvider {
|
|
|
14 |
/**
|
|
|
15 |
* MIME type for lists of entries.
|
|
|
16 |
*/
|
|
|
17 |
public static final String CONTENT_TYPE =
|
|
|
18 |
ContentResolver.CURSOR_DIR_BASE_TYPE + "/vnd.syncadapter.records";
|
|
|
19 |
/**
|
|
|
20 |
* MIME type for individual entries.
|
|
|
21 |
*/
|
|
|
22 |
public static final String CONTENT_ITEM_TYPE =
|
|
|
23 |
ContentResolver.CURSOR_ITEM_BASE_TYPE + "/vnd.syncadapter.record";
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* URI ID for route: /records
|
|
|
27 |
*/
|
|
|
28 |
public static final int ROUTE_RECORDS = 1;
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
* URI ID for route: /records/{ID}
|
|
|
32 |
*/
|
|
|
33 |
public static final int ROUTE_RECORDS_ID = 2;
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
|
|
37 |
static {
|
|
|
38 |
sUriMatcher.addURI(Constants.AUTHORITY, "records", ROUTE_RECORDS);
|
|
|
39 |
sUriMatcher.addURI(Constants.AUTHORITY, "records/*", ROUTE_RECORDS_ID);
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
@Override
|
|
|
43 |
public boolean onCreate() {
|
|
|
44 |
return true;
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
@Override
|
|
|
49 |
public String getType(Uri uri) {
|
|
|
50 |
final int match = sUriMatcher.match(uri);
|
|
|
51 |
switch (match) {
|
|
|
52 |
case ROUTE_RECORDS:
|
|
|
53 |
return CONTENT_TYPE;
|
|
|
54 |
case ROUTE_RECORDS_ID:
|
|
|
55 |
return CONTENT_ITEM_TYPE;
|
|
|
56 |
default:
|
|
|
57 |
throw new UnsupportedOperationException("Unknown uri: " + uri);
|
|
|
58 |
}
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
@Override
|
|
|
62 |
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
|
|
|
63 |
String sortOrder) {
|
|
|
64 |
|
|
|
65 |
return null;
|
|
|
66 |
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
/**
|
|
|
70 |
* Insert a new entry into the database.
|
|
|
71 |
*/
|
|
|
72 |
@Override
|
|
|
73 |
public Uri insert(Uri uri, ContentValues values) {
|
|
|
74 |
return null;
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
/**
|
|
|
78 |
* Delete an entry by database by URI.
|
|
|
79 |
*/
|
|
|
80 |
@Override
|
|
|
81 |
public int delete(Uri uri, String selection, String[] selectionArgs) {
|
|
|
82 |
return 0;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
/**
|
|
|
86 |
* Update an etry in the database by URI.
|
|
|
87 |
*/
|
|
|
88 |
@Override
|
|
|
89 |
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
|
|
|
90 |
|
|
|
91 |
return 0;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
}
|