Java Android sqlite删除
我正在尝试开发一个android应用程序,但我对SQLite有一个问题 在应用程序中,我可以添加或删除值在数据库中, 一般来说,它工作得很好,但当我添加“1.50”或“1.250”时,我的方法无法删除 删除值的方法:Java Android sqlite删除,java,android,sqlite,Java,Android,Sqlite,我正在尝试开发一个android应用程序,但我对SQLite有一个问题 在应用程序中,我可以添加或删除值在数据库中, 一般来说,它工作得很好,但当我添加“1.50”或“1.250”时,我的方法无法删除 删除值的方法: public int removeContenuWithTitre(String value){ return bdd.delete(TABLE_CONTENU, COL_VALEUR + " = " +value, null); } 使用该方法的代码:
public int removeContenuWithTitre(String value){
return bdd.delete(TABLE_CONTENU, COL_VALEUR + " = " +value, null);
}
使用该方法的代码:
buttonSup.setOnClickListener(new View.OnClickListener()
{
public void onClick(View actuelView)
{
// Si la zone de texte n'est pas vide :
if(text3.getText().length() != 0)
{
ContenuBDD contenuBdd = new ContenuBDD(MainActivity.this);
contenuBdd.open();
String valText3 = text3.getText().toString();
if(contenuBdd.recherche(valText3) == true)
{
//not removed because the value is not the database
}
else
{
// deleting the value in the database :
contenuBdd.removeContenuWithTitre(valText3);
}
contenuBdd.close();
}
else
{
}
}
});
“recherche”方法的代码,以查看数据库中是否存在值:
public boolean recherche(String titre){
Cursor c = bdd.query(TABLE_CONTENU, new String[] {COL_ID, COL_VALEUR}, COL_VALEUR + " LIKE \"" + titre +"\"", null, null, null, null);
if(c.moveToFirst() == false)
{
return true;
}
else
{
return false;
}
}
尝试:
String[] args = {value};
bdd.delete(TABLE_CONTENU, COL_VALEUR + "=?", args);