Sqlite 内存泄漏。糟糕的教程还是它的用法?
Sqlite memory leak. Bad tutorial or it's usage?
我正在尝试构建我的第一个应用程序,但遇到了 sqlite。
我明白了
W/SQLiteConnectionPool﹕ A SQLiteConnection object for database '/data/data/com.example.user.myApp/databases/testJavaNorm.sqlite' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
W/SQLiteConnectionPool﹕ A SQLiteConnection object for database '/data/data/com.example.user.myApp/databases/testJavaNorm.sqlite' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
W/SQLiteConnectionPool﹕ A SQLiteConnection object for database '/data/data/com.example.user.myApp/databases/testJavaNorm.sqlite' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
作为初学者,我使用 Sqlite tutorial。据我了解,我必须在 DB class 的末尾编写 public 方法,并像 3.
中所示那样调用它
但是 Android studio 有时会显示内存泄漏。
我注意到任何地方都没有 db.close。所以我在调用方法中添加了它,后来 public 方法。还是有漏水的。现在我读到游标也必须关闭。
我是不是用错了这个教程?或者这是一个糟糕的教程?
终于是你用过的教程了。在 if (cursor.moveToFirst()) {....}
之后必须有一个 cursor.close();
仍然:
我认为有更好的教程可用。本教程中的某些内容没有意义,例如 while 循环周围的 cursor.moveToFirst()
。 I would do this on this way.
Am I using this tutorial wrong? Or it's a bad tutorial?
这是一个非常糟糕的教程。除了您指出的错误之外,它还对文件系统路径进行了硬编码。 永远不要硬编码文件系统路径。它还完全打破了 SQLiteOpenHelper
模型。
对于想要将数据库与您的应用程序打包的具体情况,请use SQLiteAssetHelper
。
我正在尝试构建我的第一个应用程序,但遇到了 sqlite。
我明白了
W/SQLiteConnectionPool﹕ A SQLiteConnection object for database '/data/data/com.example.user.myApp/databases/testJavaNorm.sqlite' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
W/SQLiteConnectionPool﹕ A SQLiteConnection object for database '/data/data/com.example.user.myApp/databases/testJavaNorm.sqlite' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
W/SQLiteConnectionPool﹕ A SQLiteConnection object for database '/data/data/com.example.user.myApp/databases/testJavaNorm.sqlite' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
作为初学者,我使用 Sqlite tutorial。据我了解,我必须在 DB class 的末尾编写 public 方法,并像 3.
中所示那样调用它但是 Android studio 有时会显示内存泄漏。
我注意到任何地方都没有 db.close。所以我在调用方法中添加了它,后来 public 方法。还是有漏水的。现在我读到游标也必须关闭。
我是不是用错了这个教程?或者这是一个糟糕的教程?
终于是你用过的教程了。在 if (cursor.moveToFirst()) {....}
cursor.close();
仍然:
我认为有更好的教程可用。本教程中的某些内容没有意义,例如 while 循环周围的 cursor.moveToFirst()
。 I would do this on this way.
Am I using this tutorial wrong? Or it's a bad tutorial?
这是一个非常糟糕的教程。除了您指出的错误之外,它还对文件系统路径进行了硬编码。 永远不要硬编码文件系统路径。它还完全打破了 SQLiteOpenHelper
模型。
对于想要将数据库与您的应用程序打包的具体情况,请use SQLiteAssetHelper
。