Android 读取配置文件的内容

Android 读取配置文件的内容
(1)如图文件位置所示

(2)文件内容如图所示:

(3)读取其中内容:Properties props = new Properties();
     try { 
           int id = getApplicationContext().getResources().getIdentifier("androidpn", "raw", getPackageName());
           props.load(getApplicationContext().getResources().openRawResource(id));
      } catch (NotFoundException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
      } catch (IOException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
      }
        apiKey = props.getProperty("apiKey", "");
        xmppHost = props.getProperty("xmppHost","");
        xmppPort = props.getProperty("xmppPort","");
        Log.v("", "apiKey:"+apiKey+" xmppHost:"+xmppHost+" xmppPort:"+xmppPort);

你可能感兴趣的:(Android 读取配置文件的内容)