SharedPreferences sent by ACRA are all empty

334 views Asked by At

I followed the manual for implementing SharePreferences capture inside ACRA. What I basically did was including the following line in the configuration (is one of the lines of the complete configuration:

  customReportContent = { APP_VERSION, 
                       ANDROID_VERSION,
                       SHARED_PREFERENCES }
  additionalSharedPreferences={"EXTRA_MESSAGE","NOTIF_ACTIVATED"}

I followed the information from this manual and the details on this one .

However, all the preferences I received in my Cloudant database appear as empty. I made sure that ALL variables are not the default variables, specially on this 2 ones, which are changed earlier in the configuration, I tricked my code just before the message changing intentionally those variables. But, I am still receiving empty values.

I order to double check I included the email option to check what data was written by ACRA, also filling the field empty. The evidences I have: - Report at Clound Ant with SharedPreferences are empty. - The email text introduced by ACRA and offered to the user is also having the field as "empty". - No error output from ACRA in any operation

After investigating during the morning I am blocked and I don't know what else to do.

SDK21 and ACRA4.5.0 using a 2.3 android mobile.

1

There are 1 answers

0
Trebia Project. On BEST ANSWER

This was actually a wrong usage of SharePreferences in ACRA and not actually a bug in ACRA.

When the SharedPreferences is instantiated is a good practice to create a dedicated file using a code line like this one:

  String MyPREFERENCES = "MYPREFS";
  sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);

In this case "MyPREFENCES" will be the new preferences name. In order to properly use ACRA this new file needs to be explicitly added in the ACRA configuration using the following:

additionalSharedPreferences={"MYPREFS"}

The problem I was having was that I included the fields that I included in my shared preferences and NOT the preferences file that I created. Just adding the proper filename everything was working ok.