The Android system supports full-text search, which is supported by SQLite's fts3.
See:
Http://androidappdocs.appspot.com/guide/topics/search/search-dialog.html
The searching your data section.
The reason is that it is slow to use like. in Android, if like is used for query, such as like somestrin %, It is very slow. How slow is it? For a 0.1 million-row table, it may be about 1300ms. not tested by me. See:
Http://stackoverflow.com/questions/2734828/sqlite-fts3-sumulate-like-somestrin
Therefore, you must use the fts3 full-text search function supported by sqlite3.
For specific examples, see:
Http://bakhtiyor.com/2009/08/sqlite-full-text-search/
The method for running the preceding example is to decompress the package, create a new ADT project through eclipse, select an existing project, and connect to the device to run the project. from the running effect, English is correct. however, the expected results cannot be queried due to different Chinese word segmentation methods. for example, if you enter the "full-text search" four Chinese characters, insert them into the table, and search for them, the results will not be found unless you enter the "full-text search" to obtain the matching results.
This indicates that fts3 does not have proper Chinese Word Segmentation and can only be used for text word segmentation with spaces such as English.
The steps for using SQLite full-text search are as follows.
First, create a virtual table:
Create virtual table records using fts3 (integer primaery key, col_text text );
The data insertion and query API is the content provider's. insert:
Sqlitedatabase DB = getwritabledatabase ();
Contentvalues values = new contentvalues ();
Values. Put ("col_text", text );
DB. insert ("records", "col_text", values );
Query matching full-text search:
List result = new arraylist ();
Sqlitedatabase DB = getreadabledatabase ();
Final cursor = dB. Query ("records ",
New String [] {"col_text"}, "col_text" + "match ?",
New String [] {query}, null );
If (cursor. movetofirst ()){
Do {
String text = cursor. getstring (cursor
. Getcolumnindexorthrow ("col_text");
Result. Add (text );
} While (cursor. movetonext ());
}
Cursor. Close ();
Return result;