I have the following question, I'm using a listview
with a 300 character of a game, when clicking on a character it inserts some data that is written in config.properties
, all the characters have descriptions, vocations among other information many different.
The code is working correctly, but my question is the way I'm doing to insert the data would not leave the code too heavy? Is there any other right way?
Code:
Util.java
public class Util {
public static String getProperty(String key, Context context) throws IOException {
Properties properties = new Properties();;
AssetManager assetManager = context.getAssets();
InputStream inputStream = assetManager.open("config.properties");
properties.load(inputStream);
return properties.getProperty(key);
}
}
IvysaurActivity.java
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ivysaur);
//mToolbar = (Toolbar) findViewById(R.id.Toolname);
mToolbar = (TextView) findViewById(R.id.Toolname);
Number = (TextView) findViewById(R.id.Number);
Level = (TextView) findViewById(R.id.Level);
Valornpc = (TextView) findViewById(R.id.Valornpc);
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
mToolbar.setText(bundle.getString("TituloPokemon"));
if (mToolbar.getText().toString().equalsIgnoreCase("Bulbasaur")) {
try {
Number.setText(Util.getProperty("Number",getApplicationContext()));
Level.setText(Util.getProperty("Level",getApplicationContext()));
Valornpc.setText(Util.getProperty("Valornpc",getApplicationContext()));
} catch (IOException e) {
e.printStackTrace();
}
}
else
if (mToolbar.getText().toString().equalsIgnoreCase("Venusaur")) {
try {
Number.setText(Util.getProperty("Number2",getApplicationContext()));
Level.setText(Util.getProperty("Level2",getApplicationContext()));
Valornpc.setText(Util.getProperty("Valornpc2",getApplicationContext()));
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
config.properties
Number=Teste1
Level=240
Valornpc=28.000;
Number2=Teste2
Level2=540
Valornpc2=58.000;
Thank you in advance