开发者

Android, trying to save data from a class inherted from BroadcastReceiver

I’m using the AlarmManager to go offever that goes off every day to send off alarms. As it sets off an alarm, it sets a flag saying bthat alarm has gone off. I was going to save these flags in a file. I tries to use the method openFileOutput, but got a error, I’ assuming its because the class broadcastRecever DOES NOT HAVE That method. The flags are stored in a static class so the app can access them开发者_如何转开发 to. While the is running will the memory always be there? Must I save the state some how?


You can use openFileOutput: call it on the Context passed to the broadcast receiver:

@Override
public void onReceive(Context context, Intent intent)
{
  context.openFileOutput(....);
}

See http://developer.android.com/reference/android/content/Context.html#openFileOutput%28java.lang.String,%20int%29 for more detail.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜