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

写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.

 

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

SQLite的时候判断语句是否纯在:出现RuntimeException,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。