public abstract class AbstractIME extends InputMethodService implements
KeyboardView.OnKeyboardActionListener, CandidateView.CandidateViewListener {
...
private void clearCandidates() {
...
final dbhelper helper = new dbhelper(this);
Cursor c = helper.query();
}
...
}
public class CangjieDictionary extends WordDictionary {
private AbstractIME ime;
....
private String sortWords(char[] data) {
....
dbhelper dbh = new dbhelper(ime); ;
Cursor c = dbh.query();
}
}
这里有两个类。第一个没问题,但第二个代码相同
以下是 logcat 消息为什么第二类有空指针?
FATAL EXCEPTION: main
java.lang.NullPointerException
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98)
at com.googlecode.tcime.unofficial.dbhelper.query(dbhelper.java:50)
at com.googlecode.tcime.unofficial.CangjieDictionary.sortWords(CangjieDictionary.java:111)