每天在特定时间更新数据库的正确方法是什么?

Which is proper way to update database at specific time every day?

每天上午10点我必须解析一些数据,并将数据放入ORMLite数据库中。哪个是正确的方法来做到这一点?我应该使用服务吗?

您可以使用 AlarmManagerService

警报管理器 Example

服务 Example1,Example2

如果对您有帮助,请试试这个,

Calendar calendar = Calendar.getInstance();

calendar.set(Calendar.HOUR_OF_DAY, 10); // For 10 AM
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
PendingIntent pi = PendingIntent.getService(context, 0,
            new Intent(context, MyClass.class),PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
                                AlarmManager.INTERVAL_DAY, pi);