SQL那个是自己输出,用来查看SQL语句用的。
在匹配A21、A22的时候,出现了这个问题。
匹配A20,A19,A23之类的都可以的。for (int i = 0; i < c.getCount(); i++) {
item = new HashMap<String, String>();
try { item.put("name", new String(c.getBlob(0), "UTF-8"));
item.put("norm", new String(c.getString(1))); } catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
data.add(item);
c.moveToNext();
}
红字是出问题的地方。

解决方案 »

  1.   

    附上源代码~:public class ClassfiedSearchDeep extends Activity {
    private SQLiteDatabase db;
    private String sql;
    private String[] classfield; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
    setContentView(R.layout.classfydeep); final String classfied = (String) getIntent().getSerializableExtra(
    "classfied"); db = SQLiteDatabase.openOrCreateDatabase(DBManager.DB_PATH + "/"
    + DBManager.DB_NAME, null); sql = "Select additives_name,classfied From class Where classfied Like '"
    + classfied + "%' AND id>5 ";
    Log.e("sql", sql);
    Cursor c = db.rawQuery(sql, null);
    c.moveToFirst();
    String[] list1 = new String[c.getCount()];
    classfield = new String[c.getCount()];
    for (int i = 0; i < list1.length; i++) {
    try {
    list1[i] = new String(c.getBlob(0), "UTF-8");
    classfield[i] = c.getString(1);
    } catch (UnsupportedEncodingException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    c.moveToNext();
    }
    c.close();
    db.close();
    ListView listview = (ListView) findViewById(R.id.listView3);
    listview.setAdapter(new ArrayAdapter<String>(this,
    android.R.layout.simple_list_item_1, list1));
    listview.setOnItemClickListener(new ListViewClick());
    } public class ListViewClick implements OnItemClickListener {
    public void onItemClick(AdapterView<?> parent, View view, int position,
    long id) {
    newIntent(classfield[position]);
    }
    } public void newIntent(String temp) {
    Intent intent = new Intent(ClassfiedSearchDeep.this,
    ClassfiedResult.class);
    intent.putExtra("classfied", temp);
    startActivity(intent);
    }}
      

  2.   

    c.getString(1)得到的是null所以报错