โ† All Android Development Flashcard Decks

Android Data Storage Flashcards

6 cards from real Android Development practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 Android Data Storage flashcards as text
  1. Which Room annotation defines a foreign key relationship between two entities?

    Answer: @ForeignKey inside @Entity

    The @ForeignKey annotation within @Entity defines referential integrity constraints between two Room database tables.

  2. How do you perform a database migration in Room when the schema changes?

    Answer: By providing a Migration object with SQL migration scripts

    Room requires you to provide a Migration object containing the SQL statements needed to transform the old schema to the new one.

  3. What return type should a Room DAO method use to observe database changes reactively?

    Answer: Both A and B

    Room supports both Flow and LiveData as return types for DAO queries, enabling reactive observation of database changes.

  4. Which method is used to get or create an instance of a Room database?

    Answer: Room.databaseBuilder()

    Room.databaseBuilder() creates or opens a Room database with the specified context, class, and database name.

  5. What is the purpose of the @TypeConverter annotation in Room?

    Answer: To convert non-primitive types that Room cannot store natively

    @TypeConverter marks methods that tell Room how to convert a custom type to and from a type it can store in SQLite.

  6. Which file access mode should be used to append data to a file in Android?

    Answer: MODE_APPEND

    MODE_APPEND opens the file in append mode so new data is added to the end rather than overwriting existing content.