android - insert into sqlite from intentservice using sqlitecursorloader -
i using sqlitecursorloader lib commonsware. receive gcm messages in intentservice , insert entry sqlite database. should update listview if app open.
i tried using in activity loader initialized:
public static void createdbentry(string title, string message) { contentvalues values=new contentvalues(2); values.put(databasehelper.title, title); values.put(databasehelper.message, message); loader.insert("constants", databasehelper.title, values); }
and in intentservice:
mainactivity.createdbentry(title,message);
as far can tell works of time if loader recycled nullpointer.
should initialize new loader in intentservice?
please help, new android development.
putting loader
in static data member bad, loader
, let alone sqlitecursorloader
, leak activity
.
i have officially discontinued sqlitecursorloader
.
either:
switch using
contentprovider
, regularcursorloader
, oruse event bus (
localbroadcastmanager
, square's otto, greenrobot's eventbus, etc.) have service notify ui layer refresh based upon changes
Comments
Post a Comment