错误无法从int转换为boolean

太阳

我面临错误无法从int转换为boolean,这是我遇到此问题的代码。

private boolean seeDB()
  {
    int i = 1;
    SQLiteDatabase localSQLiteDatabase = null;
    try
    {
      localSQLiteDatabase = SQLiteDatabase.openDatabase(DB_PATH + DB_NAME, null, 1);
      localSQLiteDatabase = localSQLiteDatabase;
      label01: 
          if (localSQLiteDatabase != null)
        localSQLiteDatabase.close();
      if (localSQLiteDatabase != null);
      while (true)
      {
        return i;
      }
    }
    catch (SQLiteException localSQLiteException)
    {
      break label01;
    }
  }
苏雷什·阿塔(Suresh Atta)

您的方法返回类型 boolean

private boolean seeDB()

你回来了 int

 return i;

因此,该错误是正确的。

另一个错误是

  if (localSQLiteDatabase != null);   <--

这种情况到此结束 ;

最后,您应该重新考虑您的逻辑,告诉我们您要做什么。您可能会得到更好的逻辑。

这是你在做什么的一些想法

 private boolean closeDB()
      {
        SQLiteDatabase localSQLiteDatabase = null;
        try
        {
          localSQLiteDatabase = SQLiteDatabase.openDatabase(DB_PATH + DB_NAME, null, 1);
          if (localSQLiteDatabase != null){
            localSQLiteDatabase.close();
            return true; // opended DB closed 
          }else{
            return false;//  no connections opened right now.
          }

        }
        catch (SQLiteException localSQLiteException){
      }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章