由于开发初期判断上的失误,错误地以一个并不具必唯一性的字段来作为id,导致用户无法添加具体相同title的消息,以前考虑的真是太不周全了。
context = In the present, then, in loving tolerance, in loving association, ever being ready to answer when any aid or help must be given or may be given [is the best way to help someone].
context = <p>
. . . ye are part and parcel of a universal consciousness or God—and thus of all that is within the universal consciousness, or the universal awareness; as the stars, the planets, the sun, the moon. Do ye rule them or they rule thee? They were made for thy own use, as an individual—yea, that is the part, the thought thy Maker, thy Father-God thinks of thee. </p>
/**
*
* @param context
* @return boolean
* @author Samuel.Cai
* @date Mar 9, 2012
*/
public boolean alreadyExists(String context) {
//System.out.println(">>>>>>> context = " + context );
// TODO Auto-generated method stub
Cursor cursor = null;
Boolean flag = true;
if(context != null){
sd=db.getReadableDatabase();
cursor = sd.rawQuery("select * from thoughtsInfo where context=?",new String[]{context.trim()});
if(cursor.getCount() == 0){
flag = false;
}else{
flag = true;
}
}
cursor.close();
sd.close();
return flag;
}
最终结果:比较一般文本,就是把salite里面text格式字段里面值拿出来,与外面String来作比较,有些字符串可能由于编码的原因,并不一定能和自己期望的比较结果符合。
最终solution: 没有办法,只能改表结构(这次考虑很充分了,哈哈!),自己管理数据库的升级,重新发版本,自动处理用户的数据。
思路,自己通过设定标记,来执行换表结构的代码(先把用户数据从旧的表结构中取出,然后再建新表,再插入),这个并不等同于普通的数据库升级。需小心应对才是!