views:

24

answers:

1

I found that if I want to use the searchable options using the search key I have to create a content provider. Content provider is used to share data across applications.

But I do not want to allow access to my content provider (as well as my data) except/outside my own application. I want to use it only for search suggestion. Because my app data is kind of restricted.

Is there any way to implement local search without content provider? OR is is possible to apply restriction so that except my own app no other app can use my content provider? Thanks.

+1  A: 

Is there any way to implement local search without content provider?

Don't integrate with the search framework. There is nothing stopping you from having your own separate search mechanism within your app (e.g., an activity that is opened from a Search menu item).

OR is is possible to apply restriction so that except my own app no other app can use my content provider?

Your app isn't the one using the content provider -- the operating system is the one using the content provider. That's why trying to apply this sort of security is tricky. C2DM uses some related techniques, and it is possible that the core Android team will apply the same techniques to the search integration in the future, but I wouldn't hold my breath.

In the interim, either sanitize your search suggestions such that they are safe for publishing through a regular content provider, or implement your own search activity.

CommonsWare
thanks. I have read the chapter 'building a content provider' in your book 'busy coder guide to Android'. Seems the chapter needs to be more clear. esp, why the Type is needed and how to declare custom type.
karim
@karim: That chapter will be moved to the Advanced Android book and rewritten in the not-too-distant future.
CommonsWare