Source analysis of "Listviewjson" "Com.demo.app" "AppConfig" and its role in engineering

Source: Internet
Author: User

The source code is as follows:

 PackageCom.demo.app;ImportJava.io.File;ImportJava.io.FileInputStream;ImportJava.io.FileOutputStream;Importjava.util.Properties;ImportAndroid.content.Context;Importandroid.content.SharedPreferences;ImportAndroid.preference.PreferenceManager;Importcom.demo.app.common.StringUtils;/*** Application Configuration class: Used to save user related information and settings *@version1.0 * @created 2012-3-21*/ Public classAppConfig { Public Static BooleanIsfinish=true;//mainly for eject dialog whether to return    Private Final StaticString app_config = "CONFIG";  Public Final StaticString Temp_tweet = "Temp_tweet";  Public Final StaticString temp_tweet_image = "Temp_tweet_image";  Public Final StaticString temp_message = "Temp_message";  Public Final StaticString temp_comment = "Temp_comment";  Public Final StaticString temp_post_title = "Temp_post_title";  Public Final StaticString Temp_post_catalog = "Temp_post_catalog";  Public Final StaticString temp_post_content = "Temp_post_content";  Public Final StaticString Conf_app_uniqueid = "App_uniqueid";  Public Final StaticString Conf_cookie = "COOKIE";  Public Final StaticString Conf_accesstoken = "Accesstoken";  Public Final StaticString Conf_accesssecret = "Accesssecret";  Public Final StaticString conf_expiresin = "Expiresin";  Public Final StaticString conf_load_image = "Perf_loadimage";  Public Final StaticString conf_scroll = "Perf_scroll";  Public Final StaticString conf_https_login = "Perf_httpslogin";  Public Final StaticString conf_voice = "Perf_voice"; PrivateContext Mcontext; Private StaticAppConfig AppConfig;  Public StaticAppConfig Getappconfig (context context) {if(AppConfig = =NULL) {AppConfig=NewAppConfig (); Appconfig.mcontext=context; }        returnAppConfig; }        /*** Get preference Settings*/     Public Staticsharedpreferences getsharedpreferences (context context) {returnpreferencemanager.getdefaultsharedpreferences (context); }        /*** Whether to load display article pictures*/     Public Static BooleanIsloadimage (Context context) {returngetsharedpreferences (context). Getboolean (Conf_load_image,true); }             PublicString GetCookie () {returnget (Conf_cookie); }     Public voidSetaccesstoken (String accesstoken) {set (Conf_accesstoken, Accesstoken); }         PublicString Getaccesstoken () {returnget (Conf_accesstoken); }         Public voidSetaccesssecret (String accesssecret) {set (Conf_accesssecret, Accesssecret); }         PublicString Getaccesssecret () {returnget (Conf_accesssecret); }         Public voidSetexpiresin (LongExpiresin)    {Set (Conf_expiresin, string.valueof (Expiresin)); }         Public LongGetexpiresin () {returnStringutils.tolong (Get (Conf_expiresin)); }             Publicstring Get (String key) {Properties props=get (); return(props!=NULL)? Props.getproperty (Key):NULL; }         PublicProperties Get () {FileInputStream fis=NULL; Properties Props=NewProperties (); Try{            //Read config under the files directory//FIS = activity.openfileinput (app_config); //Read config under the App_config directoryFile dirconf =Mcontext.getdir (App_config, context.mode_private); FIS=NewFileInputStream (Dirconf.getpath () + File.separator +app_config);        Props.load (FIS); }Catch(Exception e) {}finally{            Try{fis.close (); } Catch(Exception e) {}}returnprops; }        Private voidSetProps (Properties p) {FileOutputStream fos=NULL; Try{            //build config in Files directory//fos = activity.openfileoutput (App_config, context.mode_private); //build config in (custom) App_config directoryFile dirconf =Mcontext.getdir (App_config, context.mode_private); File conf=NewFile (dirconf, app_config); FOS=Newfileoutputstream (conf); P.store (FOS,NULL);        Fos.flush (); }Catch(Exception e) {e.printstacktrace (); }finally{            Try{fos.close (); } Catch(Exception e) {}}}  Public voidset (Properties PS) {Properties Props=get ();        Props.putall (PS);    SetProps (props); }         Public voidSet (String key,string value) {Properties props=get ();        Props.setproperty (key, value);    SetProps (props); }         Public voidRemove (string...key) {Properties props=get ();  for(String K:key) props.remove (k);    SetProps (props); }}

Source analysis of "Listviewjson" "Com.demo.app" "AppConfig" and its role in engineering

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.