开发者

How To Get Application Context After Force closed

I integrated c2dm in my application its working fine. once c2dm notification came i do some database operation so i need the context to create OrmLiteSqliteOpenHelper object.

OrmLiteSqliteOpenHelper lDatabaseHelper = OpenHelperManager.getHelper(context.getApplicationContext());

This is fine in normal cases.

Suppose if i force stop my application manually from settings-

application->manageapplication. if any c2dm message came after i am unable to create OrmLiteSq开发者_如何学运维liteOpenHelper object. it seems application context getting null.

Exception : java.lang.IllegalStateException: Could not find OpenHelperClass because none of its generic parameters extends OrmLiteSqliteOpenHelper: null

How do i get the application context after force stopping the application.

i tried all cases: context.getApplicationContext() , context, this.

Please help me .


It might solve your problem if you explicitly tell OrmLite the name of your databasehelper class.

To do this, open res/values/strings.xml, and add

<string name="open_helper_classname">your.full.package.name.DatabaseHelper</string>

( http://ormlite.com/docs/android paragraph 5)


force the application to take a snapshot of its current state before close and reload the snapshot on loadup. You can even configure a dialogue box to select to not open up the snapshot.

-Panda

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜