<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ### 1、寫入數據APP ~~~ public class MainActivity extends Activity { private SharedPreferences putPreferences; private Editor putEditor; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // 將服務器信息寫入serverInfo.xml findViewById(R.id.buttonPut).setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub putPreferences = getSharedPreferences("serverInfo", Context.MODE_WORLD_READABLE); putEditor = putPreferences.edit(); putEditor.putString("serverIP", "192.168.1.102"); putEditor.putString("password", "123456"); putEditor.commit(); Toast.makeText(MainActivity.this,"服務器信息成功寫入serverInfo.xml", Toast.LENGTH_LONG).show(); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } ~~~ ![](https://box.kancloud.cn/2016-04-06_5704ccedee14d.jpg) ![](https://box.kancloud.cn/2016-04-06_5704ccee14e9e.jpg) ![](https://box.kancloud.cn/2016-04-06_5704ccee2c0e8.jpg) ### 2、獲取數據APP ~~~ public class MainActivity extends Activity { private SharedPreferences getPreferences; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //從serverInfo.xml獲取服務器信息 findViewById(R.id.buttonGet).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub try { Context context=createPackageContext("com.example.putprefapp", Context.CONTEXT_IGNORE_SECURITY); getPreferences=context.getSharedPreferences("serverInfo", MODE_WORLD_READABLE); String serverIP=getPreferences.getString("serverIP",""); String serverPwd=getPreferences.getString("password", ""); Toast.makeText(MainActivity.this, "服務器信息如下:IP地址:" +serverIP+"; 密碼:"+serverPwd, Toast.LENGTH_LONG).show(); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } ~~~ ![](https://box.kancloud.cn/2016-04-06_5704ccee3c181.jpg) ### 3、關于android:sharedUserId 上面的兩個工程中并沒有對android:sharedUserId屬性進行設置。這個屬性是在查資料時看到的:意思是說,在manifest.xml里面將兩個應用程序的android:sharedUserId屬性設為相同的就可以對SharedPreferences文件進行寫。(此處并沒有驗證)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看