原文地址:http://blog.csdn.net/berwinzheng/article/details/8594796

从android 里面读取配置文件

 

 
 
    
  1. private Properties loadProperties() {   
  2.  
  3.            
  4.  
  5.         Properties props = new Properties();   
  6.  
  7.         try {   
  8.  
  9.             int id = context.getResources().getIdentifier("and", "raw",   
  10.  
  11.                     context.getPackageName());   
  12.  
  13.             props.load(context.getResources().openRawResource(id));   
  14.  
  15.         } catch (Exception e) {   
  16.  
  17.             e.prinkstack();   
  18.  
  19.         }   
  20.  
  21.         return props;  
  22.  
  23.     }   
 
   
  1. props = loadProperties();   
  2.  
  3.         apiKey = props.getProperty("key", "");   
  4.  
  5.         xmppHost = props.getProperty("host", "127.0.0.1");   
  6.  
  7.         xmppPort = props.getProperty("port", "5222");   

在raw里面加入and.properties文件,内容如下
key=1234567890
host=192.168.0.121
port=5222