| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.os; |
| 18 |
|
| 19 |
import android.content.ContentProvider; |
| 20 |
import android.content.ContentValues; |
| 21 |
import android.content.Intent; |
| 22 |
import android.database.Cursor; |
| 23 |
import android.database.MatrixCursor; |
| 24 |
import android.net.Uri; |
| 25 |
|
| 26 |
import java.util.Arrays; |
| 27 |
|
| 28 |
public class SomeProvider extends ContentProvider { |
| 29 |
private Cursor mCursor; |
| 30 |
|
| 31 |
@Override |
| 32 |
public boolean onCreate() { |
| 33 |
return true; |
| 34 |
} |
| 35 |
|
| 36 |
@Override |
| 37 |
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, |
| 38 |
String sortOrder) { |
| 39 |
return mCursor; |
| 40 |
} |
| 41 |
|
| 42 |
@Override |
| 43 |
public String getType(Uri uri) { |
| 44 |
throw new UnsupportedOperationException(); |
| 45 |
} |
| 46 |
|
| 47 |
@Override |
| 48 |
public Uri insert(Uri uri, ContentValues values) { |
| 49 |
throw new UnsupportedOperationException(); |
| 50 |
} |
| 51 |
|
| 52 |
@Override |
| 53 |
public int delete(Uri uri, String selection, String[] selectionArgs) { |
| 54 |
throw new UnsupportedOperationException(); |
| 55 |
} |
| 56 |
|
| 57 |
@Override |
| 58 |
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { |
| 59 |
final char[] valueRaw = new char[512]; |
| 60 |
Arrays.fill(valueRaw, '!'); |
| 61 |
final String value = new String(valueRaw); |
| 62 |
|
| 63 |
final int count = values.getAsInteger(Intent.EXTRA_INDEX); |
| 64 |
final MatrixCursor cursor = new MatrixCursor(new String[] { "_id", "value" }); |
| 65 |
for (int i = 0; i < count; i++) { |
| 66 |
MatrixCursor.RowBuilder row = cursor.newRow(); |
| 67 |
row.add(0, i); |
| 68 |
row.add(1, value); |
| 69 |
} |
| 70 |
mCursor = cursor; |
| 71 |
return 1; |
| 72 |
} |
| 73 |
} |