I need my GCM, when I receive a message, save the information in the database, but it is giving error, it must be because the application is not open. Does anyone know what I should do? I have the following method within my GCM CommonUtilities:
public static void SaveDatabase(int remetente, int destinatario, String msg, Context context){
try{
db = dbHelper.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(DbHelper.C_REMETENTE, remetente);
values.put(DbHelper.C_DESTINATARIO, destinatario);
values.put(DbHelper.C_MSG, msg);
try{
db.insertOrThrow(DbHelper.TABLE, null, values);
}finally
{
db.close();
}
GCMIntentService.generateNotification(context, "SALVOU");
}catch(Exception e)
{
GCMIntentService.generateNotification(context, "ERRO: " + e.toString());
//GCMIntentService.generateNotification(context, e.getMessage());
//Log.e("error sqlite", e.getMessage());
}
}