简体   繁体   English

在onUpgrade方法中选择行

[英]Select rows in onUpgrade method

I have created method to select rows using getReadableDatabase() and cursors, everything is working fine, but when I try to use that method in onUpgrade, my app is crashing. 我已经创建了使用getReadableDatabase()和游标选择行的方法,一切工作正常,但是当我尝试在onUpgrade中使用该方法时,我的应用程序崩溃了。

Did someone had similar problem? 有人有类似的问题吗?

onUpgrade() is triggered by an attempt to open a database via the SQLiteOpenHelper. 通过尝试通过SQLiteOpenHelper打开数据库来触发onUpgrade()。 getReadableDatabase() uses the SQLiteOpenHelper, so calling your method from onUpgrade will cause endless recursion, and a stack overflow. getReadableDatabase()使用SQLiteOpenHelper,因此从onUpgrade调用方法将导致无限递归和堆栈溢出。

So, you'll need a version of your method that uses the database passed into the onUpgrade() method instead of calling getReadableDatabase() 因此,您将需要一个方法版本,该版本使用传递给onUpgrade()方法的数据库,而不是调用getReadableDatabase()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM