Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 连接池已在Sqlite Azure移动服务SDK中关闭_Android_Database_Sqlite_Connection_Azure Mobile Services - Fatal编程技术网

Android 连接池已在Sqlite Azure移动服务SDK中关闭

Android 连接池已在Sqlite Azure移动服务SDK中关闭,android,database,sqlite,connection,azure-mobile-services,Android,Database,Sqlite,Connection,Azure Mobile Services,在我的Android项目中,我使用Azure Mobile Services SDK,对本地sqlite数据库进行查询的方式如下所示: (示例取自) 问题是我得到了以下错误: 1) com.microsoft.windowsazure.mobileservices.table.sync.localstore.MobileServiceLocalStoreException:java.lang.IllegalStateException:无法执行此操作,因为连接池已关闭 2) 数据库“LocalD

在我的Android项目中,我使用Azure Mobile Services SDK,对本地sqlite数据库进行查询的方式如下所示: (示例取自)

问题是我得到了以下错误: 1) com.microsoft.windowsazure.mobileservices.table.sync.localstore.MobileServiceLocalStoreException:java.lang.IllegalStateException:无法执行此操作,因为连接池已关闭

2) 数据库“LocalDatabase”的SQLiteConnection对象泄漏!请修复应用程序以正确结束正在进行的事务,并在不再需要时关闭数据库

3) java.util.concurrent.ExecutionException:com.microsoft.windowsazure.mobileservices.table.sync.localstore.MobileServiceLocalStoreException:java.lang.IllegalStateException:尝试重新打开已关闭的对象

new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
    try {
        final MobileServiceList<ToDoItem> result = mToDoTable.where().field("complete").eq(false).execute().get();
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mAdapter.clear();

                for (ToDoItem item : result) {
                    mAdapter.add(item);
                }
            }
        });
    } catch (Exception exception) {
        createAndShowDialog(exception, "Error");
    }
    return null;
  }
}.execute();
newasynctask(){
@凌驾
受保护的Void doInBackground(Void…参数){
试一试{
最终MobileServiceList结果=mtodatable.where().field(“complete”).eq(false.execute().get();
runOnUiThread(新的Runnable(){
@凌驾
公开募捐{
mAdapter.clear();
for(ToDoItem项:结果){
mAdapter.添加(项目);
}
}
});
}捕获(异常){
createAndShowDialog(异常,“错误”);
}
返回null;
}
}.execute();
在此实现中,没有要关闭的游标或SQLiteOpenHelper对象。我能做什么


谢谢大家!

我认为这是因为您在一个线程中获得了结果,但试图在UI线程中使用相同的结果。一种可能的方法是在操作完成后使用广播或Eventbus将数据发送回UI:

以下是我将要做的事情:

  Futures.addCallback(mToDoTable.where().field("complete").eq(false).execute(), new FutureCallback() {
                            @Override
                            public void onSuccess(Object result) {
                                //Do something with result
                                //I would use event bus or broadcast here to notify the UI
                            }

                            @Override
                            public void onFailure(Throwable t) {

                            }
                });
如果这不起作用,我将使用调试器并在execute().get()行上放置一个断点,然后查看内部发生的情况

下面是另一种可能的方法:

   mToDoTable.where().field("complete").eq(false).execute(new TableQueryCallback<Object>() {
                    @Override
                    public void onCompleted(List result, int count, Exception exception, ServiceFilterResponse response) {

                    }
                });
mToDoTable.where().field(“complete”).eq(false).execute(新表querycallback()){
@凌驾
未完成公共void(列表结果、整数计数、异常、ServiceFilterResponse响应){
}
});