SQLite的时候判断语句是否纯在:出现RuntimeException

时间:2023-12-11 23:23:08

写SQLite的时候判断语句是否纯在:

public boolean exist(long id) {
String filter = FRIEND_KEY_ID + "=" + id;
Cursor cursor = m_db.query(DATABASE_TABLE_FRIEND,
new String[]{FRIEND_KEY_ID, FRIEND_KEY_TEXT}, filter, null, null, null, null);
if (cursor != null && cursor.getCount()>0)
{
  Log.v("Database", "Exist");
  return true;
}
else {
    Log.v("Database", "Doesn't exist");
    return false;
  }
}

04-14 11:52:17.323: E/AndroidRuntime(1058): java.lang.RuntimeException: An error occured while executing doInBackground()

An Exception is checked, and a RuntimeException is unchecked.

Checked means that the compiler requires that your handle the exeception in a catch, or declare your method as throwing it (or one of it's ancestors).

Generally, throw a checked exception if the caller of the API is expected to handle the exception, and an unchecked exception if it is something the caller would not normally be able to handle, such as an error with one of the parameters, i.e. a programming mistake.

代码修改正确后实现,开始条件语句错误