Sobes.tech
Junior

What resources are available in Android and what data can be stored in them?

sobes.tech AI

Answer from AI

In Android, the following resource types exist:

  • Drawable: Graphic resources such as images, shapes, gradients.
  • Layout: User interface layouts describing the screen structure.
  • Mipmap: Graphics for application launcher icons.
  • Values: Various values:
    • strings.xml: Text strings.
    • colors.xml: Color values in RGB or hexadecimal format.
    • dimens.xml: Dimensions (dp, sp, px, etc.).
    • styles.xml: Styles for Views.
    • themes.xml: Themes for the application.
    • arrays.xml: Arrays of strings, integers, or references to other resources.
    • bools.xml: Boolean values.
    • integers.xml: Integer values.
  • Menu: Application menu structures.
  • Raw: Arbitrary unprocessed files (audio, video, text files, etc.).
  • Xml: Arbitrary XML files that can be parsed with Android API (e.g., for data representation).
  • Font: Font files (TTF, OTF, XML). anim and animator: Animation descriptions.
  • Interpolator: Definitions of interpolators for animations.

These resources can store:

  • Images (.png, .jpg, .gif) and vector graphic files.
  • XML files describing UI layouts.
  • Text strings.
  • Color values.
  • Dimensions.
  • Style and theme descriptions.
  • Data arrays.
  • Boolean and integer values.
  • Menu and animation descriptions.
  • Arbitrary files (audio, video, text) that do not have specific processing on Android.
  • Font files.

Example of using a string resource:

<!-- res/values/strings.xml -->
<resources>
    <string name="app_name">My Application</string>
    <string name="welcome_message">Welcome!</string>
</resources>

Usage in code:

// In Activity or Fragment
String appName = getString(R.string.app_name);
TextView welcomeTextView = findViewById(R.id.welcome_text);
welcomeTextView.setText(R.string.welcome_message);