我需要你的幫助,請使用此代碼..在從SQLITE中選擇字符串時使用WHERE?
我要搜索的任何名稱,其中FIELD_CURRENCY =美元 結果將僅選擇貨幣等於美元的名稱。
private static final String FIELD_ID = "_id";
private static final String FIELD_NAME = "name";
private static final String FIELD_FLAG = "flag";
private static final String FIELD_TEL = "tel";
private static final String FIELD_CURRENCY = "currency";
private static final String TABLE_NAME = "countries";
/** Returns Countries */
public Cursor getCountries(String[] selectionArgs) {
String selection = FIELD_NAME + " like ?";
if (selectionArgs != null) {
selectionArgs[0] = "%" + selectionArgs[0] + "%";
我的表:
public class Country {
// Array of strings storing country names
static String[] countries = new String[] { "India", "Pakistan",
"Sri Lanka", "China", "test", "Nepal", "Taza",
"Test", "test2", "Japan" };
// Array of integers points to images stored in /res/drawable
static int[] flags = new int[] { R.drawable.india, R.drawable.pakistan,
R.drawable.japan, R.drawable.china, R.drawable.bangladesh,
R.drawable.japan, R.drawable.afghanistan, R.drawable.japan,
R.drawable.japan, R.drawable.japan };
// Array of strings to store currencies
static String[] tel = new String[] { "0515155",
"054545454", "045154", "0154645",
"054685", "07700125", "0750",
"07540", "07540", "07540" };
// Array of strings to store currencies
static String[] currency = new String[] { "Indian Rupee",
"Pakistani Rupee", "Sri Lankan Rupee", "Renminbi",
"dollar", "Nepalese Rupee", "Afghani",
"dollar", "South Korean Won", "dollar" };
}} 我 感謝您的幫助......
'從貨幣'%doller%';'試試這個 –