小编flp*_*flp的帖子

虽然一切都关闭了,但SQLite Connection泄露了

我发现很多东西一样close the connectionclose the cursor,但我做这一切的东西.仍然SQLite连接泄漏,我收到这样的警告:

A SQLiteConnection object for database was leaked!
Run Code Online (Sandbox Code Playgroud)

我有一个数据库管理器,我在我的活动中调用以下代码:

DatabaseManager dbm = new DatabaseManager(this);
Run Code Online (Sandbox Code Playgroud)

我的数据库管理器类的代码现在如下:

public class DatabaseManager {

    private static final int DATABASE_VERSION = 9;
    private static final String DATABASE_NAME = "MyApp";
    private Context context = null;
    private DatabaseHelper dbHelper = null;
    private SQLiteDatabase db = null;


    public static class DatabaseHelper extends SQLiteOpenHelper {

         public DatabaseHelper(Context context) {
             super(context, DATABASE_NAME, null, DATABASE_VERSION);
         }

         @Override
         public void onCreate(SQLiteDatabase db) {

                   //create database …
Run Code Online (Sandbox Code Playgroud)

android sqliteopenhelper android-sqlite

37
推荐指数
1
解决办法
2万
查看次数

如何在模块中使用'before_action'

我想在模块中使用'before_action'.

不幸的是,我无法让它发挥作用.

我是googleing,但我发现的一切都无法解决问题.

我的模块文件如下所示:

module ShowController
  include SimpleController
  #before_action :set_object, only: [:show]

  def show
   set_object
  end
end
Run Code Online (Sandbox Code Playgroud)

我想使用outcommented before_action行而不是show方法.

因此,我试图包括以下模块:

  include AbstractController::Callbacks
  include ActiveSupport::Callbacks
  include ActiveSupport::Concern
  include ActiveSupport
Run Code Online (Sandbox Code Playgroud)

另外,我试图"要求'active_support/all'"或core_ext.

我收到的error_message是:

 undefined method `class_attribute' for SimpleController::ShowController:Module
Run Code Online (Sandbox Code Playgroud)

最后,没有任何结果,我没有找到解决方案.

gem module ruby-on-rails

28
推荐指数
1
解决办法
8121
查看次数