Hi, I have been following the official Android manual to include search suggestions and searches. I work very well, but the problem is that it only searches from one database table.
I have three tables and three actions with the names "BirthdayWisher_Table" , "Tasks_Table" , "Events_Table" and "BirthdayWisher_Activity" , "Tasks_Activity" , "Events_Activity" respectively.
I want that when the user is in "BirthdayWisher_Activity" and clicks the "Search" menu item, my application should look for data from "BirthdayWisher_Table", and when the user is in "Tasks_Activity" and clicks the "Search" menu item, my application should search data from "Tasks_Table".
But for me it is impossible to do.
SearchAble Configuration File
<?xml version="1.0" encoding="utf-8"?> <searchable xmlns:android="http://schemas.android.com/apk/res/android" android:hint="@string/search" android:label="@string/app_name" android:searchSettingsDescription="@string/search_the_entire_app_" android:searchSuggestAuthority="com.beaconimpex.assistant.app.ContentProvider" android:searchSuggestIntentAction="android.Intent.action.VIEW" android:searchSuggestIntentData="content://com.beaconimpex.assistant.app.ContentProvider/BirthdayWishTable" android:searchSuggestPath="BirthdayWishTable" android:searchSuggestSelection=" suggest_text_1 LIKE ? " android:searchSuggestThreshold="1" > </searchable>
This is how I bind my searchAble operation
<activity android:name="com.beaconimpex.assistant.SearchAppActivity" android:label="@string/title_activity_search_app" > <intent-filter> <action android:name="android.intent.action.SEARCH" /> </intent-filter> <meta-data android:name="android.app.searchable" android:resource="@xml/searchable" /> </activity>
It works very well for DayWisherTable (because I pointed out)
android:searchSuggestIntentData="content://com.beaconimpex.assistant.app.ContentProvider/BirthdayWishTable" android:searchSuggestPath="BirthdayWishTable"
My content provider
public class AssistantContentProvider extends ContentProvider { public static final String DATABASE_NAME = "gcuf__dB"; public static final int DATABASE_VERSION = 99; public static final String AUTHORITY = "com.beaconimpex.assistant.app.ContentProvider"; SQLiteDatabase db; private DBOpenHelper dbHelper; private static final UriMatcher sURIMatcher = new UriMatcher( UriMatcher.NO_MATCH); private static final int SEARCH_SUGGEST = 12345; static { sURIMatcher.addURI(AUTHORITY, BirthdayWisher.TABLE_NAME + "/" + SearchManager.SUGGEST_URI_PATH_QUERY, SEARCH_SUGGEST); sURIMatcher.addURI(AUTHORITY, BirthdayWisher.TABLE_NAME + "/" + SearchManager.SUGGEST_URI_PATH_QUERY + "/*", SEARCH_SUGGEST); } @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { Log.i(MyConstants.LOG_TAG, "-----Query method is called with URI: " + uri.toString()); switch (sURIMatcher.match(uri)) { case SEARCH_SUGGEST: Log.i(MyConstants.LOG_TAG, "URI Search Suggest"); if (selectionArgs != null && selectionArgs.length > 0 && selectionArgs[0].length() > 0) {
But how can I provide special offers for each action by extracting data from related tables using this method?