Monday, November 26, 2012

[android-developers] creating shared preferences throws null pointer exception


Dear All,

  I had android doubt.

getSharedPreferences(sharedprefname, Context.MODE_PRIVATE) in a broad cast receiver returns null pointer exception?


I'm developing an android application.Im using Android SDK 2.2
I'm using 2 Broadcast receivers.Receiver A start a service S1
Receiver B starts a service S2.
Both the recievers invoked at a time interval of 1 hour
Receiver A is invoked @ a time 9.00,10.00 ,etc
Receiver B is invoked @ a time 8.50,9.50 ,etc
In a service s1 im storing some data in shared preferences
Im storing some data in shared preferences in the receiver B.
Im using the below code in the BroadCastReceiver for getting shared preference.But it throws null pointer exeption

The coding snippet given belo
context.getApplicationContext().getSharedPreferences("myPrefs_capture_gps_per_hour", Context.MODE_PRIVATE);

in the above code context is the object of the class BusinessModel.This BusinessModel class is the child class of the Application(android.app.Application)


  Give ur ideas



--
Thanks & Regards,
Sivakumar.J




--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment