Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String.xml or Constants class

What is better approach of the following in designing an Android app

  1. To place all the String constants in res/values/Strings.xml or
  2. Create a class like Constant.java where all Strings are public static final?

Choosing which one of them is more efficient?

like image 718
Its not blank Avatar asked Dec 05 '11 03:12

Its not blank


1 Answers

I imagine a constants class would be more efficient.

However, speed shouldn't really be an issue in either case. I would recommend organizing based on what makes sense.

Constants class

Put strings constants that will be used internally, like database column names or other keys.

strings.xml

Put strings that are displayed for the user. This way you can take advantage of localization, etc.

like image 192
skynet Avatar answered Oct 23 '22 11:10

skynet