Sqlite being accessed by GCM

Asked

Viewed 51 times

0

I need my GCM, when receiving a message, save the information in the database, but it is giving error, must be because the application is not open. Anybody 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());
    } 
  }
  • Gabriel, it doesn’t make much sense to make a mistake, the application is open. What is not open is the Activity (Take a look at the concept of Task and TaskStack). If you can put the error stacktrace.

  • So guy as in Try catch does not show me the error, I printed the execution and and he gives the error null, I found it very strange, remembering that this function is the same that is working in another class just copied and pasted, so the error is not the code.

  • Give a e.printStackTrace to exit the stacktrace in the log.

  • Did you find a solution? Poste as an answer to help other people.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.