Android Java 程式設計「設定/保存數據」
No Comments

發布:
更新:2015-05-17 14:14:56

使用 getSharedPreferences 函數儲存數據。

APP_NAME 改成 想設計的名稱,如:org.twgogo.wbf.Code_.web_browser

    public boolean set_config(String str,String name_){
        SharedPreferences sharedPref = getSharedPreferences("APP_NAME", MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPref.edit();
        editor.putString(name_, str);
        editor.apply();
        return true;
    }
   public String read_config(String name_){
        SharedPreferences sharedPref = getSharedPreferences("APP_NAME", MODE_PRIVATE);
        return sharedPref.getString(name_,"NULL");
    }

 


This entry was posted in Experience, Functions, Java By Weil Jimmer.

About Weil Jimmer

Hi! Everyone! My name is Weil Jimmer. This is my personal blog. I'm a webmaster of this site. I hope the site will be popular. Now, Let's go! Enjoy gaining more knowledge.
More Details About Me : https://weils.net/profile.php


Leave a message.

Only the first 10 comment will show.