锘??xml version="1.0" encoding="utf-8" standalone="yes"?> android 鏈湴鍦板潃 127.0.0.1,PC鍦板潃涓?0.0.2.2 闇瑕佽繘琛岀鍙f槧灝勶細(xì)
public SharedPreferences getSharedPreferences (String name, int mode)
Since: API Level 1
Retrieve and hold the contents of the preferences file 'name', returning a SharedPreferences through which you can retrieve and modify its values. Only one instance of the SharedPreferences object is returned to any callers for the same name, meaning they will see each other's edits as soon as they are made.
Parameters
name Desired preferences file. If a preferences file by this name does not exist, it will be created when you retrieve an editor (SharedPreferences.edit()) and then commit changes (Editor.commit()).
mode Operating mode. Use 0 or MODE_PRIVATE for the default operation, MODE_WORLD_READABLE and MODE_WORLD_WRITEABLE to control permissions. The bit MODE_MULTI_PROCESS can also be used if multiple processes are mutating the same SharedPreferences file. MODE_MULTI_PROCESS is always on in apps targetting Gingerbread (Android 2.3) and below, and off by default in later versions.
Returns
Returns the single SharedPreferences instance that can be used to retrieve and modify the preference values.
涓銆佽鍙栧唴瀹?br />
SharedPreferences preferences = getSharedPreferences("PCINFO", MODE_APPEND);
String strPort = preferences.getString("PCPORT","6699");
浜屻佸啓鍏ユ暟鎹?br />
Editor editor = preference.edit();
editor.putString("PCADDR", strAddr);
editor.putString("PCPORT", strPort);
editor.commit();
]]>
2.PC榪炲埌Android妯℃嫙鍣?/h3>
adb forward tcp:6100 tcp:7100 // PC涓婃墍鏈?span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">6100绔彛閫氫俊鏁版嵁灝嗚閲嶅畾鍚戝埌鎵嬫満绔?span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; ">7100绔彛server涓?br />
鎵浠ヨ闂甈C鏈湴鐨?100绔彛灝辯浉褰撲簬璁塊棶a(chǎn)ndroid涓婄殑7100绔彛
]]>
]]>