相关疑难解决方法(0)

java.lang.NullPointerException:println需要一条消息

我得到错误:java.lang.NullPointerException:当我调用此方法时,println需要一条消息:

lst_info = new HashMap<String, String>();
SystemDatabaseHandler db = new SystemDatabaseHandler(getApplicationContext());
lst_info = db.getLstInfo(sql_id);
Run Code Online (Sandbox Code Playgroud)

SystemDatabaseHandler:

public HashMap<String , String> getLstInfo(int id){
    HashMap<String , String> lst_temp;
    lst_temp = new HashMap<String , String>();

    String selectQuery = "SELECT * FROM dkr_lst_lst WHERE lst_id = " + id;
    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);
    if (cursor.moveToFirst()) {
        do {
            Log.d("sql_id", cursor.getString(0));
            lst_temp.put("sql_id", cursor.getString(0));
        }while (cursor.moveToNext());
    } 
    cursor.close();
    db.close();
    return lst_temp;
}
Run Code Online (Sandbox Code Playgroud)

Log.d("sql_id",cursor.getString(0)); 收益:

07-12 11:56:05.603:D/sql_id(13783):1

Log Cat:

07-12 11:56:05.613: D/Database(13783): dbclose(): …
Run Code Online (Sandbox Code Playgroud)

android hashmap nullpointerexception println

22
推荐指数
2
解决办法
5万
查看次数

标签 统计

android ×1

hashmap ×1

nullpointerexception ×1

println ×1