应用程序随机崩溃

时间:2017-05-08 18:27:08

标签: java android

我正在制作我的第一款安卓游戏。它几乎完成了。它大部分时间运行良好没有任何问题,但偶尔应用程序在进入得分/高分页面时停止工作。它崩溃并在logcat中显示以下消息:

05-08 11:20:14.341 2478-2487/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/networkstatistics.sqlite' was leaked!  Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
05-08 11:20:14.632 2478-2487/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/metrics.db' was leaked!  Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
05-08 11:20:14.633 2478-2487/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/help_responses.db.18' was leaked!  Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.
05-08 11:20:14.636 2478-2487/com.google.android.gms W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.google.android.gms/databases/auto_complete_suggestions.db' was leaked!  Please fix your application to end transactions in progress properly and to close the database when it is no longer needed.

有人可以告诉我如何解决这个问题吗? (这并不总是发生。有时会崩溃。)

1 个答案:

答案 0 :(得分:1)

假设您正在使用SQLite数据库,请关闭它的对象,例如 db.close(),其中db是datbase的对象,同时确保在使用后也关闭了游标对象,使用 cursor.close()

未能这样做,会抛出这些运行时异常。