开发者

What is xml format/schema for shared preferences in Android?

Below is how SharedPreferences are read from a file, but what is xml format/schema for SharedPreferences file? How is it different from format for regular pref开发者_StackOverflow社区erences? where is this schema posted? And which directory should the file reside in?

public static final String PREF_FILE_NAME = "PrefFile";
SharedPreferences preferences = getSharedPreferences(PREF_FILE_NAME, MODE_PRIVATE);


I don't think there is a formal schema. You can infer the format by looking at what it outpus though. Open up DDMS in Eclipse, and browse to /data/data/<your package>/shared_prefs. For example, you'll find:

<map>
  <int name="id" value="1" />
  <string name="first">John</string>
</map>

You might want to consider reading in your initialization values and using the SharedPreferences API to persist them. This way, you can be sure that SharedPreferences will write it's file in the correct place.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜