3
我想在android應用程序上創建配置文件,我知道 Xcode我們使用plist,Dot net使用app.config但對於Android I 沒有想法創建文件。如何創建屬性文件android
謝謝
我想在android應用程序上創建配置文件,我知道 Xcode我們使用plist,Dot net使用app.config但對於Android I 沒有想法創建文件。如何創建屬性文件android
謝謝
對於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
那好先生可以通過使用SharedPreferences
。
你能解釋這多一點好嗎? – ConquerorsHaki