By : Ketan Bhimani
348
a content provider is to store the information you want to share in
a SQLite database.
One example is a content provider for GPS track points. This
content provider enables users of it to query for points and store
points. The data for each point contains a time stamp, the latitude
and longitude, and the elevation.
Implementing a Content Provider Interface
Implementing a content provider interface is relatively
straightforward. The following code shows the basic interface that
an application needs to implement to become a content provider,
requiring implementations of five important methods:
public class TrackPointProvider extends ContentProvider {
public int delete(Uri uri,
String selection, String[] selectionArgs) {
return 0;
}
public String getType(Uri uri) {
return null;
}
public Uri insert(Uri uri, ContentValues values) {
return null;
}
public boolean onCreate() {
return false;
}
public Cursor query(Uri uri, String[] projection,
String selection, String[] selectionArgs, String sortOrder) {
return null;
}
public int update(Uri uri, ContentValues values,
String selection, String[] selectionArgs) {
return 0;
}
}