Note: I've tested this solution on CM12.
Three answers saying the same thing but are rather extreme in their approach. I want to remove one query out of dozens I made. Why should I remove everything just to remove one? Not fair!
First things first:
In Android, it's possible to search for a specific setting by clicking the magnifying glass in the top right corner of the settings app and typing.
I don't think that's true for any stock ROM. This seems to be a CM specific feature, and based on the tags, the ROM is CM12.1.
It is an assumption that if you're using Cyanogenmod then the device would be rooted. Considering it to be the case, install SQLite Editor.
The queries that you make using the lens icon are saved in a table
saved_queries with time-stamp, under the database
search_index.db, located in the data directory of Settings (
- Launch SQLite Editor
- Under Apps tap Settings (
- Tap search_index.db, or do a Full Scan if you don't see the entry
- Go to saved_queries
- Choose the search query you don't want to see in Settings, and select the trash icon at the top
Changes would take place immediately. If not, force-close the Settings app from Settings → Apps → All → Settings, and then proceed with aforesaid instructions. You may optionally reboot as well.
I heard that you like fancy stuff
You can use adb to achieve the goal. The commands would be:
This command would give you the schema of
adb shell su -c 'sqlite3 /data/data/com.android.settings/databases/search_index.db ".schema saved_queries"'
Output would be:
CREATE TABLE saved_queries(query VARCHAR(64) NOT NULL, timestamp INTEGER);
The columns are
timestamp. Use this resource to know the details about sqlite commands.
List all the entries in the table
adb shell su -c 'sqlite3 /data/data/com.android.settings/databases/search_index.db "SELECT * from saved_queries"'
Output would be like:
The output is in the order of schema you saw in the last command.
Select and delete your search query from the table:
adb shell su -c 'sqlite3 /data/data/com.android.settings/databases/search_index.db "DELETE from saved_queries where query=\"pin\""'
You can confirm from the last command that your query is gone for good from the table, and so as from the search entries listed under lens icon of Settings app.
As said in first part, you can force-close the Settings app if needed. Do:
adb shell su -c 'am force-stop com.android.settings'
You can use a terminal app like Terminal Emulator to achieve the goal as well. Simply do
su, and then follow the
sqlite3 commands (i.e. remove
adb shell su -c '' from the commands).
Screenshots before and after tweaks:
(Click image to enlarge; hover to see detail)
For Non-rooted devices
No salvation other than doing Settings → Apps → All → Settings → Force Stop → Clear data, as suggested in other answers. (Don't bother about this step because your custom settings are saved in Settings Storage app (
com.android.providers.settings)). You can't access the data directory of Settings app since you don't meet the privileges to access it.
Furthermore, you can't do tinkering with backup taken using
adb backup either as
android:allowBackup="false" is declared in Manifest file of Settings, which means no backup is allowed at all.
We're good to go now!