記錄我寫與數據庫record.its比較,但將所有的記錄比較數據庫記錄是否存在
public void onClick(View v) {
if(v.equals(add))
{
if(ifExisting())
{
insert();
Log.e("Data Inserting","true");
Intent i=new Intent(AddCategory.this,ShareFolioActivity.class);
startActivity(i);
//Toast.makeText(AddCategory.this, "Already exists",Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(AddCategory.this, "Already exists",Toast.LENGTH_LONG).show();
Log.e("Data Inserting","false");
}
}
}
boolean ifExisting() {
Log.e("wquery","SELECT * FROM sharelist WHERE category='"+category.getText().toString()+"'");
Cursor c = db.rawQuery("SELECT category FROM sharelist WHERE category='"+category.getText().toString()+";'",null);
if(c.getCount()==-1)
{
Log.e("Condition true","true");
return false;
}
else
{
Log.e("Condition true","false");
return true;
}
}
現在任何記錄都沒有輸入(即:顯示「已存在」) – sri 2010-12-18 06:03:59