androidinterview.com

Android System Design Interview Questions

34 questions

Library Design

  • Design an image loading library.

    Hard

    Load an image from a URL into an ImageView through four stages, memory cache, disk cache, network fetch, then decode, with each stage there to make the next one unnecessary. Around the pipeline sit

  • Design an LRU cache.

    Hard

    A hash map for O(1) lookup plus a doubly linked list for O(1) reordering, so get and put are both constant time. That is the whole data structure. The rest of the answer is why neither half works

  • Design a caching library.

    Hard

    The design is a Cache<K, V> with a memory tier in front of an optional disk tier. Entries are evicted by bytes rather than by count, and expiry is checked lazily on read. This is the general-purpose

  • Design a file downloader library.

    Hard

    A priority queue in front of a small pool of resumable transfers. Each one writes to a temporary file, persists its byte offset as it goes, and renames into place only once the file is whole. The

  • Design a logging library.

    Hard

    A logging library is a leveled API in front of a set of swappable trees, with a batching writer behind the tree that persists to disk. The API has to be cheap enough to leave switched on in hot

  • Design a networking library.

    Hard

    This is asking you to justify the shape of something like Retrofit plus OkHttp, not necessarily rebuild it from raw sockets. The useful way to answer is to name the layers and why each one exists,

  • Design an analytics library.

    Hard

    A track() call validates the event, stamps it with an id and an identity, appends it to a queue on disk, and returns. Everything after that belongs to a background worker. Tracking an event can never

App & Feature Design

Caching & Offline

Offline and caching is where a mobile design round almost always ends up, because it is the part that separates mobile design from backend design.

Data & Security

Less common, worth knowing

These come up less often. Skim them once you are comfortable with everything above.

Library Design

  • Design an image downloading library.

    Hard

    One download per URL however many callers ask for it, behind a per host permit. The bytes are committed into a disk cache through a temporary file and handed back to callers on their own thread.

App & Feature Design

Data & Security

  • What is the SMS Retriever API in Android?

    Easy

    The SMS Retriever API lets your app automatically read a one-time verification code from an incoming SMS, without asking the user for the READSMS or RECEIVESMS permission.

  • How do you get accurate time in Android?

    Medium

    You do not get trustworthy wall clock time from the device, because the user can set it to anything. So you ask a source you trust once, and from then on you count forward with a clock the user