I am developing an android app where I have some pdf files stored in asset folder. On click of list items the files open through available pdf viewer. The following code runs fine in versions lower than Kitkat. But as Kitkat have its own Storage Access Framework(SAF) the code only opens the framework not the file.
FileContentProvider.java
public class FileContentProvider extends ContentProvider
{
#Override
public String getType(Uri uri)
{
return "application/pdf";
}
#Override
public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException
{
AssetManager am = getContext().getAssets();
String file_name = uri.getLastPathSegment();
if (file_name == null) throw new FileNotFoundException();
AssetFileDescriptor afd = null;
try
{
afd = am.openFd(file_name+ ".mp3");
}
catch (IOException e)
{
e.printStackTrace();
}
return afd;
}
private final static String[] COLUMNS = {OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE};
#Override
/**
* This function is required for it to work on the Quickoffice at Android 4.4 (KitKat)
*/
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
{
if (projection == null)
{
projection = COLUMNS;
}
String[] cols = new String[projection.length];
Object[] values = new Object[projection.length];
int i = 0;
for (String col : projection)
{
if (OpenableColumns.DISPLAY_NAME.equals(col))
{
cols[i] = OpenableColumns.DISPLAY_NAME;
values[i++] = uri.getLastPathSegment();
}
else if (OpenableColumns.SIZE.equals(col))
{
cols[i] = OpenableColumns.SIZE;
values[i++] = AssetFileDescriptor.UNKNOWN_LENGTH;
}
}
cols = copyOf(cols, i);
values = copyOf(values, i);
final MatrixCursor cursor = new MatrixCursor(cols, 1);
cursor.addRow(values);
return cursor;
}
private static String[] copyOf(String[] original, int newLength)
{
final String[] result = new String[newLength];
System.arraycopy(original, 0, result, 0, newLength);
return result;
}
private static Object[] copyOf(Object[] original, int newLength)
{
final Object[] result = new Object[newLength];
System.arraycopy(original, 0, result, 0, newLength);
return result;
}
#Override
public boolean onCreate()
{
return true;
}
#Override
public Uri insert(Uri uri, ContentValues values)
{
return null;
}
#Override
public int delete(Uri uri, String selection, String[] selectionArgs)
{
return 0;
}
#Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs)
{
return 0;
}
}
The code block from where it is called:
if(android.os.Build.VERSION.SDK_INT <19) {
i = new Intent(Intent.ACTION_VIEW);
}
else {
i = new Intent();
}
/**Open PDF Forms*/
String fileName = "af1_version_7_december_2013.pdf";
i.setDataAndType(Uri.parse("content://package_name/"+fileName), "application/pdf");
try {
startActivity(i);
}
catch (ActivityNotFoundException e)
{
Toast.makeText(getActivity(), "NO Pdf Viewer", Toast.LENGTH_SHORT).show();
}
After debugging I have seen that for Kitkat the Kitkat specific code in my FileContentProvider.java is not accessed.
Please let me know if anyone have the solution to this problem. My sincere thanks in advance.
Note: This question is not duplicate as previous questions and answers were not Kitkat specefic and after my detailed search I've found that there is no solution in stack overflow to this question as of now.
Related
I have two app, from another app I want to get all images,
suppose there is StickerProvider and MainActivity different app
StickerProvider is ContentProvider, MainActivity has ContentResolver
StickerProvider App has Asset Folder
Asset----> Stickers ----------> a.png, b.png
public class StickerProvider extends ContentProvider {
private final static String LOG_TAG = StickerProvider.class.getName();
private static final String[] COLUMNS = {
OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE};
#Override
public boolean onCreate() {
return true;
}
#Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
/**
* Source: {#link FileProvider#query(Uri, String[], String, String[], String)} .
*/
if (projection == null) {
projection = COLUMNS;
}
String[] images = new String[0];
try {
images = getContext().getAssets().list("stickers");
ArrayList<String> listImages = new ArrayList<String>(Arrays.asList(images));
final MatrixCursor cursor = new MatrixCursor(new String[]{"path"}, 1);
for (int i = 0; i < listImages.size(); i++) {
cursor.addRow(new String[]{listImages.get(i)});
}
return cursor;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
#Override
public String getType(Uri uri) {
/**
* Source: {#link FileProvider#getType(Uri)} .
*/
final String file_name = uri.getLastPathSegment();
final int lastDot = file_name.lastIndexOf('.');
if (lastDot >= 0) {
final String extension = file_name.substring(lastDot + 1);
final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
if (mime != null) {
return mime;
}
}
return "image/png";
}
#Override
public Uri insert(Uri uri, ContentValues values) {
return null;
}
#Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
#Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
return 0;
}
}
It's menifest file is
<provider
android:name="com.example.StickerProvider"
android:authorities="com.example"
android:exported="true"
android:grantUriPermissions="true"
android:label="StickerProvider" />
Another app is MainActivity ------> From this I want to fetch all images of above apps
public class MainActivity extends AppCompatActivity {
int i=0;
private static final String TAG = "MainActivity";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView ivOne = (ImageView)findViewById(R.id.ivOne);
ImageView ivTwo = (ImageView)findViewById(R.id.ivTwo);
try {
ContentResolver resolver = getContentResolver();
Cursor cursor =
resolver.query(Uri.parse("content://com.example/stickers"),
null,
null,
null,
null);
if (cursor.moveToFirst()) {
do {
String word = cursor.getString(0);
if(i==0){
ivOne.setImageURI(Uri.parse("content://com.example/stickers/"+word));
}else if(i==1){
ivTwo.setImageURI(Uri.parse("content://com.example/stickers/"+word));
}
// do something meaningful
Log.d(TAG, "onCreate: "+word);
} while (cursor.moveToNext());
}
}catch(Exception e){
e.printStackTrace();
}
}
}
When ever I start MainActivity App I am getting below exception
Unable to open content: content://com.example/a.png
java.io.FileNotFoundException: No files supported by provider at content://com.example/a.png
at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:144)
at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:692)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1149)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:986)
at android.content.ContentResolver.openInputStream(ContentResolver.java:706)
at android.widget.ImageView.getDrawableFromUri(ImageView.java:900)
at android.widget.ImageView.resolveUri(ImageView.java:871)
at android.widget.ImageView.setImageURI(ImageView.java:490)
at android.support.v7.widget.AppCompatImageView.setImageURI(AppCompatImageView.java:124)
at com.pixr.photo.collage.MainActivity.onCreate(MainActivity.java:36)
at android.app.Activity.performCreate(Activity.java:6684)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2652)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2766)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1507)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6236)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)
ivOne.setImageURI(Uri.parse("content://com.example/stickers/"+word));
Your ContentProvider does not support this. It does not implement openFile() or any of its variants.
Either:
Use an existing ContentProvider that offers support for serving assets, such as my StreamProvider, or
Augment your provider to support openFile(), such as I do in this sample app
ic_launcher is related with app icon. There is no app icon. Check your icon in your drawable directory.
so here is my problem, i need to get a file in phone and then upload it to my parse-server. I've made a file chooser for document, download, external, media folder but android file chooser also propose GoogleDrive option. So i got te Uri but i can't find a way to access that "local copy?".
Do i need to use GoogleDrive SDK to access it? Or can't android just be smart enough and give me methods to handle that Uri ?
I did success getting file name.
content://com.google.android.apps.docs.storage/document/
Here is my file chooser and handler:
public static void pick(final Controller controller) {
final Intent chooseFileIntent = new Intent(Intent.ACTION_GET_CONTENT);
chooseFileIntent.setType("application/pdf");
chooseFileIntent.addCategory(Intent.CATEGORY_OPENABLE);
if (chooseFileIntent.resolveActivity(controller.getContext().getPackageManager()) != null) {
controller.startActivityForResult(chooseFileIntent, Configuration.Request.Code.Pdf.Pdf);
}
}
private static boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
}
private static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
}
private static boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
}
private static boolean isGooglePhotosUri(Uri uri) {
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
}
private static boolean isGoogleDriveUri(Uri uri) {
return "com.google.android.apps.docs.storage".equals(uri.getAuthority());
}
private static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
Cursor cursor = null;
final String column = "_data";
final String[] projection = { column };
try {
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
if (cursor != null && cursor.moveToFirst()) {
final int index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(index);
}
} finally {
if (cursor != null)
cursor.close();
}
return null;
}
private static String getPath(Context context, Uri uri) {
if (DocumentsContract.isDocumentUri(context, uri)) {
if (isExternalStorageDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
if ("primary".equalsIgnoreCase(type)) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}
} else if (isGoogleDriveUri(uri)) {
// Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
// if (cursor != null) {
// int fileNameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
// cursor.moveToFirst();
// Log.d("=== TAG ===", cursor.getString(fileNameIndex));
// Log.d("=== TAG ===", uri.getPath());
// cursor.close();
// }
} else if (isDownloadsDocument(uri)) {
final String id = DocumentsContract.getDocumentId(uri);
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
return getDataColumn(context, contentUri, null, null);
} else if (isMediaDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
final String selection = "_id=?";
final String[] selectionArgs = new String[] {split[1]};
return getDataColumn(context, contentUri, selection, selectionArgs);
}
}
else if ("content".equalsIgnoreCase(uri.getScheme())) {
if (isGooglePhotosUri(uri))
return uri.getLastPathSegment();
return getDataColumn(context, uri, null, null);
}
else if ("file".equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
}
return null;
}
public static void upload(final Context context, final String name, final ParseObject dataSource, final String field, final Uri uri, final Handler handler) {
if (context != null && name != null && dataSource != null && field != null && uri != null) {
String path = getPath(context, uri);
if (path != null) {
final File file = new File(path);
dataSource.put(field, new ParseFile(file));
dataSource.getParseFile(field).saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
if (handler != null) {
handler.success();
}
}
}
}, new ProgressCallback() {
#Override
public void done(Integer percentDone) {
if (handler != null) {
handler.progress(percentDone);
}
}
});
}
}
}
EDIT :
I've made some try but i got a problem when deleting the temporary file
Here is my code:
public static void copyFile(final Context context, final Uri uri, final ParseObject dataSource, final String field, final String name, final Data.Source target, final Handler handler) {
new AsyncTask<Void, Void, Boolean>() {
#Override
protected Boolean doInBackground(Void... params) {
try {
InputStream inputStream = context.getContentResolver().openInputStream(uri);
if (inputStream != null) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bytes = new byte[1024];
int length;
while ((length = inputStream.read(bytes)) != -1) {
byteArrayOutputStream.write(bytes, 0, length);
}
dataSource.put(field, new ParseFile(name, byteArrayOutputStream.toByteArray()));
byteArrayOutputStream.close();
inputStream.close();
return true;
} else {
return false;
}
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
#Override
protected void onPostExecute(final Boolean success) {
dataSource.getParseFile(field).saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
if (handler != null) {
handler.success();
}
}
}
}, new ProgressCallback() {
#Override
public void done(Integer percentDone) {
if (handler != null) {
handler.progress(percentDone);
}
}
});
}
}.execute();
}
Final Edit:
Here my code is correct, temporary file are created and put in cache by Parse himself, so its out of my range. Hope he can help.
So i got te Uri but i can't find a way to access that "local copy?".
There is no "local copy", at least one that you can access.
Or can't android just be smart enough and give me methods to handle that Uri ?
Use ContentResolver and openInputStream() to get an InputStream on the content identified by the Uri. Either use that directly with your "parse-server", or use it to create a temporary "local copy" to a file that you control. Upload that local copy, deleting it when you are done.
Here is my file chooser and handler:
pick() is fine. upload() might be fine; I have not used Parse. The rest of that code is junk, copied from prior junk. It makes many unfounded, unreliable assumptions, and it will not work for Uri values from arbitrary apps (e.g., served via FileProvider).
If I use ContentProvider in my app am getting error like "unfortunately camera has stopped" after Result_ok.This is my code:
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(MediaStore.EXTRA_OUTPUT, MyFileContentProvider.CONTENT_URI);
startActivityForResult(i, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
How to to solve this?I don't want to save image in sd card.
This my MyFileContentProvider class:
public class MyFileContentProvider extends ContentProvider {
public static final Uri CONTENT_URI = Uri.parse("content://com.example.user.studentadmission/");
private static final HashMap<String, String> MIME_TYPES = new HashMap<String, String>();
static {
MIME_TYPES.put(".jpg", "image/jpeg");
MIME_TYPES.put(".jpeg", "image/jpeg");
}
#Override
public boolean onCreate() {
try {
File mFile = new File(getContext().getFilesDir(), "student.jpg");
if(!mFile.exists()) {
mFile.createNewFile();
}
getContext().getContentResolver().notifyChange(CONTENT_URI, null);
return (true);
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
#Override
public String getType(Uri uri) {
String path = uri.toString();
for (String extension : MIME_TYPES.keySet()) {
if (path.endsWith(extension)) {
return (MIME_TYPES.get(extension));
}
}
return (null);
}
#Override
public ParcelFileDescriptor openFile(Uri uri, String mode)
throws FileNotFoundException {
File f = new File(getContext().getFilesDir(), "student.jpg");
if (f.exists()) {
return (ParcelFileDescriptor.open(f,
ParcelFileDescriptor.MODE_READ_WRITE));
}
throw new FileNotFoundException(uri.getPath());
}
#Override
public Cursor query(Uri url, String[] projection, String selection,
String[] selectionArgs, String sort) {
throw new RuntimeException("Operation not supported");
}
#Override
public Uri insert(Uri uri, ContentValues initialValues) {
throw new RuntimeException("Operation not supported");
}
#Override
public int update(Uri uri, ContentValues values, String where,
String[] whereArgs) {
throw new RuntimeException("Operation not supported");
}
#Override
public int delete(Uri uri, String where, String[] whereArgs) {
throw new RuntimeException("Operation not supported");
}
}
Few camera action works only on Kitkat, use condition for action:
Intent i = (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT)
? new Intent(MediaStore.ACTION_IMAGE_CAPTURE_SECURE)
: new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(MediaStore.EXTRA_OUTPUT, MyFileContentProvider.CONTENT_URI);
startActivityForResult(i, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
If still crash occur, try avoiding ContentProvider just for testing. Let me know.
Give permission for open Camera.
Give run-time permission for open Camera.
Hi I'm try to save different files with ContentProvider (videos and photos).But I don't know how to do it in the same class.
I try to do this...
public class MyFileContentProvider extends ContentProvider {
public static final Uri CONTENT_URI = Uri.parse("content://com.renata.ideary/picture");
public static final Uri CONTENT_URI_2 = Uri.parse("content://com.renata.ideary/video");
private static final HashMap<String, String> MIME_TYPES = new HashMap<String, String>();
private static final HashMap<String, String> MIME_TYPES_2= new HashMap<String, String>();
static {
MIME_TYPES.put(".jpg", "image/jpeg");
MIME_TYPES.put(".jpeg", "image/jpeg");
MIME_TYPES_2.put(".mp4","video/mp4");
}
#Override
public boolean onCreate() {
try {
File mFile = new File(getContext().getFilesDir(), "/picture.jpg");
if(!mFile.exists()) {
mFile.createNewFile();
}
File mFile2 = new File(getContext().getFilesDir(), "/video.mp4");
if(!mFile2.exists()) {
mFile2.createNewFile();
}
getContext().getContentResolver().notifyChange(CONTENT_URI, null);
getContext().getContentResolver().notifyChange(CONTENT_URI_2, null);
return (true);
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
#Override
public String getType(Uri uri) {
String path = uri.toString();
for (String extension : MIME_TYPES.keySet()) {
if (path.endsWith(extension)) {
return (MIME_TYPES.get(extension));
}
}
for (String extension : MIME_TYPES_2.keySet()) {
if (path.endsWith(extension)) {
return (MIME_TYPES_2.get(extension));
}
}
return (null);
}
#Override
public ParcelFileDescriptor openFile(Uri uri, String mode)
throws FileNotFoundException {
if (uri.equals(CONTENT_URI)) {
File f = new File(getContext().getFilesDir(), "/picture.jpg");
if (f.exists()) {
return (ParcelFileDescriptor.open(f,
ParcelFileDescriptor.MODE_READ_WRITE));
}
throw new FileNotFoundException(uri.getPath());
}
else {
File f2 = new File(getContext().getFilesDir(), "/video.mp4");
if (f2.exists()) {
return (ParcelFileDescriptor.open(f2,
ParcelFileDescriptor.MODE_READ_WRITE));
}
throw new FileNotFoundException(uri.getPath());
}
}
#Override
public Cursor query(Uri url, String[] projection, String selection,
String[] selectionArgs, String sort) {
throw new RuntimeException("Operation not supported");
}
#Override
public Uri insert(Uri uri, ContentValues initialValues) {
throw new RuntimeException("Operation not supported");
}
#Override
public int update(Uri uri, ContentValues values, String where,
String[] whereArgs) {
throw new RuntimeException("Operation not supported");
}
#Override
public int delete(Uri uri, String where, String[] whereArgs) {
throw new RuntimeException("Operation not supported");
}
}
But always told me the same error:
05-06 22:42:37.932 21837-21849/com.renata.ideary E/JavaBinder: *** Uncaught remote exception! (Exceptions are not yet supported across processes.)
java.lang.RuntimeException: Operation not supported
at com.renata.ideary.MyFileContentProvider.query(MyFileContentProvider.java:137)
at android.content.ContentProvider.query(ContentProvider.java:980)
at android.content.ContentProvider$Transport.query(ContentProvider.java:213)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:112)
at android.os.Binder.execTransact(Binder.java:446)
Someone can help me? Thanks
PD: Save my video but with that error :(
I want to ask, if is there some way to get ParseObjects to Search suggestions-box in Android. I've succesully created recent-query suggestions and it worked well. But right now do I need to put there one string collection from Parse.com while the user is typing -show results, which contain the query which is being typed. I am kind of desperated because I've been searching for it for a week and no result.
Do you have any idea, how to accomplish that?
My in normal ParseQuery in SearchActivity:
ParseQuery<Animal> squery = ParseQuery.getQuery(Animal.class);
squery.whereMatches("animal", query, "i");
squery.findInBackground(new FindCallback<Animal>() {
#Override
public void done(List<Animal> animals, ParseException error) {
if(animals != null){
nAdapter.clear();
for (int i = 0; i < animals.size(); i++) {
mProgressBar = (ProgressBar) findViewById(R.id.search_loading_animals);
mProgressBar.setVisibility(View.INVISIBLE);
nAdapter.add(animals.get(i));
}
}
}
});
SuggestionAdapter to which do i need to implement the ParseQuery:
public class SuggestionProvider extends ContentProvider {
private static final String TAG = "SuggestionProvider";
private static final int SEARCH_SUGGESTIONS = 1;
private static final UriMatcher sURLMatcher = new UriMatcher(
UriMatcher.NO_MATCH);
static {
sURLMatcher.addURI("*", SearchManager.SUGGEST_URI_PATH_QUERY,
SEARCH_SUGGESTIONS);
sURLMatcher.addURI("*", SearchManager.SUGGEST_URI_PATH_QUERY + "/*",
SEARCH_SUGGESTIONS);
}
private static final String[] COLUMNS = new String[] {
"_id",
SearchManager.SUGGEST_COLUMN_TEXT_1,
SearchManager.SUGGEST_COLUMN_INTENT_ACTION,
SearchManager.SUGGEST_COLUMN_QUERY
};
public SuggestionProvider() {
}
#Override
public boolean onCreate() {
return true;
}
#Override
public Cursor query(Uri url, String[] projectionIn, String selection,
String[] selectionArgs, String sort) {
int match = sURLMatcher.match(url);
switch (match) {
case SEARCH_SUGGESTIONS:
String query = url.getLastPathSegment();
MatrixCursor cursor = new MatrixCursor(COLUMNS);
String[] suffixes = { "", "a", " foo", "XXXXXXXXXXXXXXXXX" };
for (String suffix : suffixes) {
Toast.makeText(getContext(), "", Toast.LENGTH_SHORT).show();
addRow(cursor, query + suffix);
}
return cursor;
default:
throw new IllegalArgumentException("Unknown URL: " + url);
}
}
private void addRow(MatrixCursor cursor, String string) {
long id = cursor.getCount();
cursor.newRow().add(id).add(string).add(Intent.ACTION_SEARCH).add(string);
}
#Override
public String getType(Uri url) {
int match = sURLMatcher.match(url);
switch (match) {
case SEARCH_SUGGESTIONS:
return SearchManager.SUGGEST_MIME_TYPE;
default:
throw new IllegalArgumentException("Unknown URL: " + url);
}
}
#Override
public int update(Uri url, ContentValues values, String where, String[] whereArgs) {
throw new UnsupportedOperationException("update not supported");
}
#Override
public Uri insert(Uri url, ContentValues initialValues) {
throw new UnsupportedOperationException("insert not supported");
}
#Override
public int delete(Uri url, String where, String[] whereArgs) {
throw new UnsupportedOperationException("delete not supported");
}
}