Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Super Contributor
Achin
Posts: 425
Registered: ‎01-02-2013
My Device: BOLD 9900
My Carrier: sdvsdvsd
Accepted Solution

string match with in database

i have database having more then 2000 rows which contains strings like

(for eg-Teach the children not to receive anything for nothing; let them earn by hardwork the things they seek.)

and i have editfield and a button now what i want is when the user enter any word to edit field,
it will match that word with all the strings ,if the match is found that will return all the strings that having the enterd word
for eg- i have enter 'Teach' in the edit fied and click to the search button that will match with my strings in my DataBase
and it will show me all the strings having that word.

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: string match with in database

http://www.w3schools.com/sql/sql_like.asp
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
peter_strange
Posts: 19,602
Registered: ‎07-14-2008
My Device: Not Specified

Re: string match with in database

Simon is suggesting that you can do this with SQL commands.  Here is a sample - this has been heavily edited so will probably not run, but does give you all the processing.

 

Look at the SQLiteDemo for more.

 

            String dataBaseLocation = ...;
            URI myURI = URI.create(dataBaseLocation);
            d = DatabaseFactory.open(myURI);
            String SQLSelect = "SELECT description, url, title " +
                               "FROM Book" + tableName + ' ' +
                               "WHERE title LIKE '%" + keyWord + "%' " +
                               "LIMIT " + limit;
            Statement st = d.createStatement(SQLSelect);
            st.prepare();
            c = st.getCursor();
            Row r;
            long rowCount = 0;
            // Extract details from each row returned. 
            while ( c.next() ) {
                r = c.getRow();
                rowCount++;
                String description = r.getString(0);
                String link = r.getString(1);
                String title = r.getString(2);
                // add to a colledction to be displayed on screen. 
            }
            c.close();
            d.close();

 

 

 

Please use plain text.