错误创建共享preferences - 无法为共享preferences文件创建目录 [英] Error creating SharedPreferences - couldn't create directory for SharedPreferences file

查看:2890
本文介绍了错误创建共享preferences - 无法为共享preferences文件创建目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图创建一个共享preferences从服务文件时,出现以下错误:

I am getting the following error when trying to create a shared preferences file from a service:

无法为共享preferences文件/dbdata/databases/dimappers.android.pub/shared_$p$pfs/PubStore2.xml创建目录

"Couldn't create directory for SharedPreferences file /dbdata/databases/dimappers.android.pub/shared_prefs/PubStore2.xml"

我使用的是三星Galaxy S I9000测试和我读别的地方有关的问题与此特定手机。不过,我发誓这是在一个正常的活动有一定点的工作(但无可否认无法得到它的工作了......)

I am using a Samsung Galaxy S I9000 to test and I have read else where about problems with this specific phone. However, I swear it was working at some point in a normal activity (though admittedly can't get it to work any more...)

Editor editor = getSharedPreferences(Constants.SaveDataName, MODE_PRIVATE).edit();
editor.putString(Constants.SaveDataName, xmlString);
editor.commit();

如果我称之为

String s = getSharedPreferences(Constants.SaveDataName, MODE_PRIVATE).getString(Constants.SaveDataName, "");

在调用commit后Immeditately它能够得到它,但如果我重新启动应用程序,它是不是能够找到它。

Immeditately after calling commit it is able to get it, but if I restart the app it isn't able to find it.

推荐答案

这似乎是我的手机(三星Galaxy S I9000),它的工作(尽管仍然显示出错误),但在另一部手机上运行相同的code没有显示的错误消息。

It appeared to be my phone (Samsung Galaxy S I9000), it worked (albeit still showing that error) but running the same code on another phone didn't show the error message.

这篇关于错误创建共享preferences - 无法为共享preferences文件创建目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆