我收到“java.lang.StackOverflowError”错误。
这是代码:
08-30 10:34:49.528: E/AndroidRuntime(22897): FATAL EXCEPTION: main
08-30 10:34:49.528: E/AndroidRuntime(22897): java.lang.StackOverflowError
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications.java:28)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.RejectedNotifications.<init>(RejectedNotifications.java:27)
08-30 10:34:49.528: E/AndroidRuntime(22897): at com.silm.database.ApprovedNotifications.<init>(ApprovedNotifications
关于该项目:
为什么我想做:
我想单击批准按钮将通知/消息保存到批准的通知/消息数据库中。但我注意到,当我点击 Aprrove 按钮时,它被插入,当点击 Rejected 按钮时,它也被插入到 Rejected 表中。因此,我检查是否不在拒绝表中,然后将其插入到批准表中。那时一切都很好,但是当我做同样的事情时(从批准中删除通知并插入拒绝),然后我得到了 StackOverFlow 错误。
这是生成错误的代码:
public RejectedNotifications(Context context) {
super(context, TABLE_NAME_REJECTED_NOTIFICATION, null, DATABASE_VERSION);
***approved = new ApprovedNotifications(context);***
}
表 Approved 的另一个数据库处理程序类似于关于代码:
public ApprovedNotifications(Context context) {
super(context, TABLE_NAME_APPROVED_NOTIFICATION, null, DATABASE_VERSION);
rejected = new RejectedNotifications(context);
}