This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Android and the fly likes SharedPreferences problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "SharedPreferences problem" Watch "SharedPreferences problem" New topic
Author

SharedPreferences problem

Naishadh Parmar
Ranch Hand

Joined: Jun 02, 2011
Posts: 95



I have this code:



But I get this error:

Couldn't create directory for SharedPreferences file /data/data/org.quens.xno/shared_prefs/org.quens.xno.xml

I don't knwo what's the problem. I tried to look up on the net, but no results.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Is org.quens.xno the application you are writing? Because it looks like you don't have permissions to write in that context.


Steve
Naishadh Parmar
Ranch Hand

Joined: Jun 02, 2011
Posts: 95


No it is the package. This code is from the class org.quens.xno.MainActivity.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Hrm... are you testing in the emulator or on your real phone? What version of Android? There seemed to be a problem with Samsung in version 2.x that had this problem. Another thing to try would be to use the android adb tools to connect to the device and see if the file already exists - perhaps another app had created one with the same name?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SharedPreferences problem