CommonsWare's suggestion would be a smart hack, but unfortunately this will not work.
Samsung does not always put the shared_prefs directory in the same parent directory as getFilesDir() .
I would recommend checking for availability (hardcode it, except for the package name): /dbdata/databases/<package_name>/shared_prefs/package.name_preferences.xml , and if it exists, use it, otherwise refer to the CommonsWare new File(getFilesDir(), "../shared_prefs") or simply /data/data/<package_name>/shared_prefs/package.name_preferences.xml .
Warning, although this method may have problems if the user switched from a Samsung drive to a custom rum without cleaning, since the /dbdata/databases file may not be used, but still exists.
More details
On some Samsung devices, such as the Galaxy S series running on froyo, the setting is as follows:
/data/data/<package_name>/(lib|files|databases)
Sometimes there are shared_prefs, but Samsung is just trying to embarrass you! Do not believe it! (I think this can happen if you switch from version 2.1 to 2.2, but it can be a disconnection from users switching roms. I really donβt know, I just included an application error report in my interface, and sometimes I see both files )
and
/dbdata/databases/<package_name>/shared_prefs
This is the real shared_prefs directory.
However, on the Galaxy Tab on Froyo, this is weird. Usually you have: /data/data/<package_name>/(lib|shared_prefs|files|databases)
Without the /dbdata/databases/<package_name> , but it seems that system applications have: /dbdata/databases/<package_name>/yourdatabase.db
And the added bonus is that /dbdata/databases/<package_name> not deleted when your application is deleted. Good luck using SharedPreferences if a user ever reinstalls your application!
Kevin TeslaCoil
source share