Android - SQLiteDatabase配置数据库错误警告

时间:2016-06-07 12:01:28

标签: android android-sqlite

我在应用程序中面临与SQLiteDatabase相关的一个问题。应用程序没有崩溃。这是我在Logcat中收到的日志。

 D/SQLiteDatabase:dispose database false
            java.lang.Throwable: stacktrace
            at android.database.sqlite.SQLiteDatabase.dispose(SQLiteDatabase.java:286)
            at android.database.sqlite.SQLiteDatabase.onAllReferencesReleased(SQLiteDatabase.java:280)
            at android.database.sqlite.SQLiteClosable.releaseReference(SQLiteClosable.java:74)
            at android.database.sqlite.SQLiteClosable.close(SQLiteClosable.java:106)
            at com.demo.model.SQLiteManager.close(SQLiteManager.java:74)
            at com.demo.ui.ContactFragment$ContactListAdapter.fetchContactData(ContactFragment.java:295)
            at com.demo.ui.ContactFragment$ContactListAdapter.<init>(ContactFragment.java:336)
            at com.demo.ui.ContactFragment$4.onQueryTextChange(ContactFragment.java:224)
            at android.support.v7.widget.SearchView.onTextChanged(SearchView.java:1150)
            at android.support.v7.widget.SearchView.access$2000(SearchView.java:103)
            at android.support.v7.widget.SearchView$12.onTextChanged(SearchView.java:1680)
            at android.widget.TextView.sendOnTextChanged(TextView.java:8340)
            at android.widget.TextView.setText(TextView.java:4413)
            at android.widget.TextView.setText(TextView.java:4252)
            at android.widget.EditText.setText(EditText.java:90)
            at android.widget.TextView.setText(TextView.java:4227)
            at android.support.v7.widget.SearchView.setQuery(SearchView.java:585)
            at com.demo.ui.ContactFragment.onPause(ContactFragment.java:153)
            at android.support.v4.app.Fragment.performPause(Fragment.java:2139)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1117)
            at android.support.v4.app.FragmentManagerImpl.detachFragment(FragmentManager.java:1408)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:727)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
            at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
            at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
            at android.support.v4.view.ViewPager.populate(ViewPager.java:1177)
            at android.support.v4.view.ViewPager.populate(ViewPager.java:1025)
            at android.support.v4.view.ViewPager$3.run(ViewPager.java:254)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:912)
            at android.view.Choreographer.doCallbacks(Choreographer.java:714)
            at android.view.Choreographer.doFrame(Choreographer.java:646)
            at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:898)
            at android.os.Handler.handleCallback(Handler.java:815)
            at android.os.Handler.dispatchMessage(Handler.java:104)
            at android.os.Looper.loop(Looper.java:207)
            at android.app.ActivityThread.main(ActivityThread.java:5769)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

以上错误是否正常?

下面是代码。在调用close()方法时,我遇到了错误。

public static synchronized SQLiteManager getInstance(Context context) {

    if (mInstance == null) {
            mInstance = new SQLiteManager(context.getApplicationContext());
    }
        return mInstance;
    }

    public SQLiteDatabase open(boolean getWritable) throws SQLException {
        if (getWritable) {
            database = MySQLiteHelper.getInstance(mContext).getWritableDatabase();
        } else {
            database = MySQLiteHelper.getInstance(mContext).getReadableDatabase();
        }
        return database;
    }

    public void close() {
        database.close();
    }

0 个答案:

没有答案