【问题标题】:how to create properties file android如何创建属性文件android
【发布时间】:2014-03-13 09:43:03
【问题描述】:

我想在 android 应用程序上创建配置文件,我知道 对于 Xcode 我们使用 plist,Dot net 使用 app.config 但对于 android 我 没有创建文件的想法。

谢谢

【问题讨论】:

    标签: android app-config configuration-files


    【解决方案1】:

    使用SharedPreferences 可以实现这位好先生。

    【讨论】:

    • 你能解释一下吗?
    【解决方案2】:

    对于 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

    【讨论】:

      猜你喜欢
      • 2013-08-22
      • 1970-01-01
      • 2013-08-20
      • 1970-01-01
      • 2014-03-01
      • 2019-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多