2014-03-13 51 views

回答

3

對於android應用程序我找到了創建app.properties文件的方法,在已經創建了app.properties之後,很容易從.properties文件中獲取數據。例如下面的:

public void CreatePropertiesFile(Context context) 
{ 
Properties prop = new Properties(); 
String propertiesPath = context.getFilesDir().getPath().toString() + "/app.properties"; 
try { 
FileOutputStream out = new FileOutputStream(propertiesPath); 
     prop.setProperty("HomeVersion", "0"); 
prop.setProperty("DatePlaySquare", "0"); 
prop.setProperty("CustomerID", "0"); 
prop.setProperty("DeviceToken", "0"); 
prop.setProperty("CurrentVersionMobile", "0"); 
prop.setProperty("Domain", "Megazy"); 
prop.setProperty("DownloadNewVersion","0"); 
     prop.store(out, null); 
     out.close(); 
} catch (IOException e) { 
    System.err.println("Failed to open app.properties file"); 
    e.printStackTrace(); 
} 

Aey.Sakon