0

I am reading a .properties file in android which is stored in assets folder. My .properties file has almost 8000-9000 key value pairs. For loading it is taking almost 4 minutes. Below is my code for reading the .properties file.

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

When executing line props.load(inputStream) it is taking almost 4 minutes to complete. I am using Eclipse and executing my code in MOTO G mobile in developer mode.

Below is my sample .properties file values.

AB=HELLO CD=WORLD
like this there were 8000 key value pairs.
Please let me know is there any problem in my code or any other way to do it fast. Thanks!!

reVerse
  • 35,075
  • 22
  • 89
  • 84
anonymous
  • 483
  • 2
  • 8
  • 24
  • You should use a database table, to handle so many data. – Phantômaxx Dec 30 '14 at 18:04
  • Is the properties file something you're editing at runtime? If so, have you considered making a hardcoded lookup table, or maybe a databse table? Do you have to load all the properties up front? Can they be loaded by a service at startup? – Stealth Rabbi Dec 30 '14 at 18:06

1 Answers1

0
  1. Have you tried executing the code without debugger attached? Debugger slows down memory access by 10 times.
  2. Have you consider using String.xml instead of using a plain file?
uDevel
  • 1,891
  • 1
  • 13
  • 14