我在我的SQL数据库中保存了数据.
现在我想用字符串比较这个保存的数据
像这样的东西:
String example = "house";
Run Code Online (Sandbox Code Playgroud)
现在我想检查,如果"house"已经在数据库中,带有if子句
这样的事情
if ( example == [SQL Data] ) {
}
else {
}
Run Code Online (Sandbox Code Playgroud)
现在,我该怎么做到这一点?
做点什么
String sql = "SELECT * FROM your_table WHERE your_column = '" + example + "'";
Cursor data = database.rawQuery(sql, null);
if (cursor.moveToFirst()) {
// record exists
} else {
// record not found
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17768 次 |
| 最近记录: |