-3

I have to parse some data every day at 10 AM, and to put data in a ORMLite database. Which is proper way to do this? Should I use a service?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Filip Rosca
  • 601
  • 1
  • 6
  • 13

2 Answers2

0

Try this if it helps you out,

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);
Harshal Benake
  • 2,391
  • 1
  • 23
  • 40
-1

you can use AlarmManageror Service.

Alarm Manager Example

Service Example1,Example2

Community
  • 1
  • 1
karimkhan
  • 321
  • 3
  • 18