3
votes

We're having a crash when starting the app and it tries to create the shared preferences and read from the database. It happens in different devices, mostly HTCs but also LGs, that are running Gingerbread, and they are not rooted.

E/ApplicationContext(2630): Couldn't create directory for SharedPreferences file /data/data/com.example.project/shared_prefs/com.example.project_preferences.xml

E/Database(2630): sqlite3_open_v2("/data/data/com.example.project/databases/project.db", &handle, 6, NULL) failed

We're initializing SharedPreferences with Roboguice.

Uninstalling the app and re-installing it seems to help, but we don't have a way to say that to our users.

I've looked around and found that people usually have this problem in rooted devices or in specific Samsung devices.

Thanks in advance!

Note: our real package name is unique, I've changed it on the code above so it's not public.

2
I see this sort of thing in my error reports as well. I think there's a bug in the OS that occasionally leaves apps without the ability to access their own files, etc.. Frequently triggered by OS updates. Uninstall and reinstall is the only solution I've found. I suppose you could write your app such that it saves everything to SD card/internal storage instead of the app's protected storage.Lance Nanek
Thanks Lance! That's where we're seeing it, in our crittercism crash reports. We think it's an OS problem as well. Thanks for the suggestion, we can try that!cperes

2 Answers

2
votes

You need to add the permissions in your AndroidManifest.xml:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

I have the same problem with you, and I solved it with the above solution. I think you must forget the permissions, too. Try it.

1
votes

I would suggest that you change the package name of your application from com.example.project to something more unique. Probably the users who have this problem have another application installed on their device using the same package name, thereby causing a conflict.