I would like to create the config file on android application and I know for Xcode we use plist, Dot net uses app.config but for android I don't have an idea to create file.

Thank you

有帮助吗?

解决方案 2

for android application I found the way to create app.properties file, after already app.properties created it's easy to get data from .properties file. Example's below:

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

其他提示

That good sir is possible by using SharedPreferences.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top