阅读" .properties" Android中的文件花费了太多时间

时间:2014-12-30 17:56:39

标签: android performance android-assets

我正在阅读android中的.properties文件,该文件存储在assets文件夹中。我的.properties文件有近8000-9000个键值对。装载时间大约需要4分钟。以下是我阅读.properties文件的代码。

Properties props = new Properties();
AssetManager assets = resources.getAssets();
InputStream inputStream = assets.open("details.properties");
props.load(inputStream);

执行第props.load(inputStream)行时,需要将近4分钟才能完成。我正在使用Eclipse并在开发人员模式下在MOTO G mobile中执行我的代码。

以下是我的示例.properties文件值。

AB=HELLO CD=WORLD
像这样有8000个键值对 请告诉我代码中是否有任何问题或以其他任何方式快速完成。谢谢!

1 个答案:

答案 0 :(得分:0)

  1. 您是否尝试过未附加调试程序的代码?调试器将内存访问速度降低10倍。
  2. 您是否考虑使用String.xml而不是使用普通文件?