• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps "Search by" after import an Excel file

Take out the angle brackets from your query

Code:
db.execSQL("SELECT Company FROM " + tableName + " WHERE Company like " + etSearch.getText() + "%");
 
Take out the angle brackets from your query

Code:
db.execSQL("SELECT Company FROM " + tableName + " WHERE Company like " + etSearch.getText() + "%");

When I click on EditText and type "S" from Samsung for example the application stops and the error is:
Java:
FATAL EXCEPTION: main
                                                                          android.database.sqlite.SQLiteException: near "%": syntax error (code 1): , while compiling: SELECT Company FROM proinfo WHERE Company like S%
 
You need to surround the search value with single quotes. And I recommend that you read a tutorial on Sqlite.

Code:
SELECT Company FROM proinfo WHERE Company like 'S%'
 
Back
Top Bottom