How to insert values in xml file after installing apk on device?



I want to get notification pop up on specific device for that I want to save that device mobile number into xml file.


in database table if new entry is there for that mobile number (I will check new entry using select query on database table)


If entry is present I will call following Alarm code which will show notification on that device.


Is it possible to save values into xml after installation is done on device?



public void setRepeatingAlarm() {
Intent intent = new Intent(MainActivity.this, TimeAlarm.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,
intent, PendingIntent.FLAG_UPDATE_CURRENT);

am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+172800000,
(172800000), pendingIntent);
}

//alarm class
public class TimeAlarm extends BroadcastReceiver {

NotificationManager nm;

@Override
public void onReceive(Context context, Intent intent) {

Intent notificationIntent = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);

Notification noti = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setTicker("Sanjay Wabale")
//.setLargeIcon(largeIcon)
//.setWhen(System.currentTimeMillis()+1000)
.setContentTitle("Sanjay Wabale")
.setContentText("Check updated information!")
.setContentIntent(contentIntent)
//At most three action buttons can be added
.setAutoCancel(true).build();
int notifyID =0;
notificationManager.notify(notifyID, noti);

}

}

No comments:

Post a Comment