3

I am getting the following error only on Samsung device. Went through this but it doesn't really provide a solution.

Couldn't create directory for SharedPreferences file shared_prefs/log_files.xml

To be specific:

enter image description here

This is how I have declared SharedPreferences in onCreate

settings = getSharedPreferences("preferences", MODE_PRIVATE);  
Cœur
  • 37,241
  • 25
  • 195
  • 267
Nitish
  • 13,845
  • 28
  • 135
  • 263
  • can you be more specific which samsung + os version + original rom? – Bojan Kseneman May 04 '15 at 12:44
  • @BojanKseneman : Samsung Galaxy S5 - 5.0 – Nitish May 04 '15 at 12:47
  • `private static SharedPreferences getPrefs() { return SomeApplication.getInstance().getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); }` this code is working on our S5 5.0, try changing the name "preferences" tough I doubt that's the issue – Bojan Kseneman May 04 '15 at 12:55

2 Answers2

4

Based on a similar post it looks as if this error is specific to Samsung devices; this was confirmed by multiple users -

Error creating SharedPreferences - couldn't create directory for SharedPreferences file

It might be worthwhile to open an issue.

Community
  • 1
  • 1
Willis
  • 5,308
  • 3
  • 32
  • 61
  • I agree. Is there a way we can handle this. Atleast the crash in the App. I have try catch in place though. – Nitish May 01 '15 at 17:40
  • 1
    Could you post some more of your code so I can get an idea of what you are trying to do? – Willis May 01 '15 at 18:00
-1

Follow the link given below for shared preference API called TinyDB You can use this which handles your problem.

https://github.com/kcochibili/TinyDB--Android-Shared-Preferences-Turbo

Vinay Jayaram
  • 1,030
  • 9
  • 29