当前位置: 代码迷 >> SQL >> sqlife查询出错及关键字加粗方式
  详细解决方案

sqlife查询出错及关键字加粗方式

热度:46   发布时间:2016-05-05 11:26:31.0
sqlife查询报错及关键字加粗方式

sqlife查询报错及关键字加粗的实现示例简单记录如下:

/**	 * 搜索知识点	 * @param query	 * @return	 */	public List<KnowledgePoint> searchKnowledgePoints(String query , String subjectId) {				if(query == null){			return null;		}				KnowledgePoint kp = null;		List<KnowledgePoint> kpList = new ArrayList<KnowledgePoint>();				/**		 * 防止用户输入'号引起崩溃		 */		query = query.replace("'", "''");		        String sql = "select * from " + TABLE_NAME_KNOWLEDGE_POINT + " where subject_id=? and point_name like ?";		SQLiteDatabase db = this.getReadableDatabase();		String[] argv = new String[] {subjectId , "%" + query + "%"};        Cursor cursor = db.rawQuery(sql, argv);        while (cursor.moveToNext()) {        	        	kp = new KnowledgePoint();        	        	kp.setSubjectId(cursor.getString(0));        	kp.setKid(cursor.getString(2));        	kp.setParentId(cursor.getString(3));        	/**        	 * 搜索关键字变粗        	 */        	kp.setName(cursor.getString(4).replace(query , "<strong>"+query+"</strong>"));        	kp.setIcon(cursor.getInt(5));        	        	kpList.add(kp);        }                cursor.close();        this.closeDB();        return kpList;	}

?

  相关解决方案