<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shakibaenur</title>
    <description>The latest articles on DEV Community by Shakibaenur (@shakibaenur).</description>
    <link>https://dev.to/shakibaenur</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1020798%2Fba35e3f2-4ae6-4915-a128-6733d51178b0.jpg</url>
      <title>DEV Community: Shakibaenur</title>
      <link>https://dev.to/shakibaenur</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shakibaenur"/>
    <language>en</language>
    <item>
      <title>A Mind Map for Mobile System Design Preparation</title>
      <dc:creator>Shakibaenur</dc:creator>
      <pubDate>Wed, 02 Sep 2026 09:03:17 +0000</pubDate>
      <link>https://dev.to/shakibaenur/a-mind-map-for-mobile-system-design-preparation-2m5l</link>
      <guid>https://dev.to/shakibaenur/a-mind-map-for-mobile-system-design-preparation-2m5l</guid>
      <description>&lt;p&gt;Mobile system design interviews can feel overwhelming.&lt;/p&gt;

&lt;p&gt;You're asked to design something that sounds simple — a news feed, chat application, ride-sharing app, video platform, or social network — but suddenly you're expected to reason about much more than UI and API calls.&lt;/p&gt;

&lt;p&gt;You need to think about application architecture, networking, caching, offline support, synchronization, concurrency, storage, performance, security, observability, and sometimes even how the backend interacts with the mobile client.&lt;/p&gt;

&lt;p&gt;The difficult part isn't that any one of these topics is impossible to learn.&lt;/p&gt;

&lt;p&gt;The difficult part is knowing &lt;strong&gt;which topics matter, how they connect, and how to apply them during an interview.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's what this guide is about.&lt;/p&gt;

&lt;p&gt;We'll build a mental model for mobile system design interviews and walk through the major areas you should prepare.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is Mobile System Design?
&lt;/h2&gt;

&lt;p&gt;Mobile system design is an interview format where you're given a product or feature and asked to design the architecture of a mobile application that supports it.&lt;/p&gt;

&lt;p&gt;For example, an interviewer might ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How would you design a news feed app?&lt;/li&gt;
&lt;li&gt;How would you build a chat application?&lt;/li&gt;
&lt;li&gt;How would you design a ride-sharing app?&lt;/li&gt;
&lt;li&gt;How would you support offline editing in a mobile application?&lt;/li&gt;
&lt;li&gt;How would you design a video streaming application?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The answer isn't simply:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I'll create a UI, call an API, and display the response."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A production mobile application has many layers.&lt;/p&gt;

&lt;p&gt;A simplified architecture might look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────┐
│          UI Layer           │
│ SwiftUI / UIKit             │
│ Jetpack Compose / Views     │
└──────────────┬──────────────┘
               │
┌──────────────▼──────────────┐
│       Domain / Business     │
│          Logic              │
└──────────────┬──────────────┘
               │
┌──────────────▼──────────────┐
│          Data Layer         │
│ API • Cache • Database      │
└──────────────┬──────────────┘
               │
        ┌──────▼──────┐
        │   Network   │
        └──────┬──────┘
               │
        ┌──────▼──────┐
        │   Backend   │
        └─────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's only the beginning.&lt;/p&gt;

&lt;p&gt;The application also has to deal with things that are particularly important on mobile:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;unreliable networks&lt;/li&gt;
&lt;li&gt;limited battery&lt;/li&gt;
&lt;li&gt;limited memory&lt;/li&gt;
&lt;li&gt;intermittent connectivity&lt;/li&gt;
&lt;li&gt;background execution restrictions&lt;/li&gt;
&lt;li&gt;application lifecycle changes&lt;/li&gt;
&lt;li&gt;device storage constraints&lt;/li&gt;
&lt;li&gt;different screen sizes and hardware&lt;/li&gt;
&lt;li&gt;application updates&lt;/li&gt;
&lt;li&gt;security of data stored on the device&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is what makes mobile system design different.&lt;/p&gt;




&lt;h1&gt;
  
  
  A Mind Map for Mobile System Design Preparation
&lt;/h1&gt;

&lt;p&gt;Because mobile system design combines many areas of software engineering, preparing topic-by-topic can quickly become confusing.&lt;/p&gt;

&lt;p&gt;You might study caching today, API design tomorrow, and Android lifecycle the next day — without understanding how they fit together.&lt;/p&gt;

&lt;p&gt;A better approach is to organize your preparation into a few major areas.&lt;/p&gt;

&lt;p&gt;This guide divides mobile system design into nine sections:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Mobile Domain&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;API Design &amp;amp; Networking&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Software Architecture &amp;amp; Design Patterns&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data Storage&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Performance &amp;amp; Optimization&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Observability &amp;amp; Testing&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Privacy &amp;amp; Security&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Advanced Topics&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Interview Strategy&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Think of these as the major branches of your preparation.&lt;/p&gt;




&lt;h1&gt;
  
  
  1. Mobile Domain
&lt;/h1&gt;

&lt;p&gt;The first area is understanding the mobile platform itself.&lt;/p&gt;

&lt;p&gt;You don't necessarily need to memorize every framework API. Instead, you should understand the constraints and architectural decisions that mobile platforms impose.&lt;/p&gt;

&lt;h2&gt;
  
  
  UI Frameworks
&lt;/h2&gt;

&lt;p&gt;Modern mobile development generally has two broad approaches.&lt;/p&gt;

&lt;h3&gt;
  
  
  Declarative UI
&lt;/h3&gt;

&lt;p&gt;You describe what the UI should look like for a particular state.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SwiftUI on iOS&lt;/li&gt;
&lt;li&gt;Jetpack Compose on Android&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, a screen might conceptually be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;State
  ↓
UI
  ↓
User Action
  ↓
State Update
  ↓
UI Recomposition
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This model is particularly useful when discussing state management and unidirectional data flow.&lt;/p&gt;

&lt;h3&gt;
  
  
  Imperative UI
&lt;/h3&gt;

&lt;p&gt;The application explicitly creates and modifies UI components.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UIKit on iOS&lt;/li&gt;
&lt;li&gt;XML/code-based Views on Android&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In an interview, the important question isn't usually which framework you prefer.&lt;/p&gt;

&lt;p&gt;It's understanding &lt;strong&gt;how UI state flows through your architecture&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Lifecycle Management
&lt;/h2&gt;

&lt;p&gt;Mobile applications don't run continuously like a server.&lt;/p&gt;

&lt;p&gt;The operating system can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;move your application to the background&lt;/li&gt;
&lt;li&gt;suspend it&lt;/li&gt;
&lt;li&gt;terminate it&lt;/li&gt;
&lt;li&gt;recreate screens&lt;/li&gt;
&lt;li&gt;reclaim memory&lt;/li&gt;
&lt;li&gt;restore state later&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On iOS, you'll encounter concepts such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;UIViewController&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;AppDelegate&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SceneDelegate&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;SwiftUI view lifecycle&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On Android, important concepts include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Activity&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Fragment&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Application&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Jetpack Compose lifecycle&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This becomes important when designing features such as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What happens if the user starts uploading a file and leaves the application?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The answer requires much more than UI code.&lt;/p&gt;




&lt;h1&gt;
  
  
  Threading and Concurrency
&lt;/h1&gt;

&lt;p&gt;Mobile applications have a main thread responsible for responsive UI work.&lt;/p&gt;

&lt;p&gt;Blocking that thread with expensive operations can result in a poor user experience or even an application that appears frozen.&lt;/p&gt;

&lt;p&gt;A simplified model is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                ┌───────────────┐
                │   Main Thread │
                │ UI / Events   │
                └───────┬───────┘
                        │
                 Dispatch Work
                        │
              ┌─────────▼─────────┐
              │ Background Workers │
              │ Network / CPU / DB │
              └────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On iOS, you should understand concepts such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Grand Central Dispatch (GCD)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;OperationQueue&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;async/await&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Tasks&lt;/li&gt;
&lt;li&gt;Actors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On Android, important concepts include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Looper&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Handler&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;thread pools&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ThreadPoolExecutor&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Kotlin Coroutines&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;During system design interviews, you should be able to identify work that should &lt;strong&gt;not&lt;/strong&gt; happen on the main thread.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UI Thread
   │
   ├── Render UI
   ├── Handle user interaction
   │
   └── Dispatch expensive work
              │
              ├── Network request
              ├── Database query
              ├── Image processing
              └── File processing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Navigation
&lt;/h1&gt;

&lt;p&gt;Navigation becomes especially interesting when your application supports deep links.&lt;/p&gt;

&lt;p&gt;Imagine a user taps a notification:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Push Notification
       ↓
   Deep Link
       ↓
   Application
       ↓
   Authentication Check
       ↓
   Target Screen
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On iOS, common concepts include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;UINavigationController&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;SwiftUI &lt;code&gt;NavigationStack&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Coordinator patterns&lt;/li&gt;
&lt;li&gt;Deep Links&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On Android:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigation Component&lt;/li&gt;
&lt;li&gt;Deep Links&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The system design question isn't simply:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"How do I navigate to another screen?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead, consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What happens when the user isn't logged in?&lt;/li&gt;
&lt;li&gt;What happens when the application was terminated?&lt;/li&gt;
&lt;li&gt;How do you restore the navigation state?&lt;/li&gt;
&lt;li&gt;What happens if the target resource no longer exists?&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Data Binding and State Propagation
&lt;/h1&gt;

&lt;p&gt;A mobile application often has several components interested in the same data.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;             Repository
                 │
        ┌────────┼────────┐
        │        │        │
      Home    Profile   Details
        │        │        │
        └────────┴────────┘
                 │
                UI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On iOS, you may encounter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Combine&lt;/li&gt;
&lt;li&gt;KVO&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ObservableObject&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;completion handlers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On Android:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LiveData&lt;/li&gt;
&lt;li&gt;Kotlin Flow&lt;/li&gt;
&lt;li&gt;StateFlow&lt;/li&gt;
&lt;li&gt;Coroutines&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The important system-design concept is &lt;strong&gt;how state moves through the application without creating inconsistent or duplicated state&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  2. API Design and Networking
&lt;/h1&gt;

&lt;p&gt;The mobile client is only one side of a distributed system.&lt;/p&gt;

&lt;p&gt;The application communicates with backend services through a network that may be slow, unreliable, or completely unavailable.&lt;/p&gt;

&lt;p&gt;This makes networking one of the most important areas of mobile system design.&lt;/p&gt;

&lt;h2&gt;
  
  
  Communication Protocols
&lt;/h2&gt;

&lt;p&gt;You should understand the tradeoffs between:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;REST&lt;/li&gt;
&lt;li&gt;GraphQL&lt;/li&gt;
&lt;li&gt;WebSockets&lt;/li&gt;
&lt;li&gt;gRPC&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Protocol&lt;/th&gt;
&lt;th&gt;Common Use Case&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;REST&lt;/td&gt;
&lt;td&gt;General API communication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GraphQL&lt;/td&gt;
&lt;td&gt;Flexible client-driven data fetching&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WebSockets&lt;/td&gt;
&lt;td&gt;Persistent real-time communication&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;gRPC&lt;/td&gt;
&lt;td&gt;Efficient service-to-service communication&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The right choice depends on the requirements.&lt;/p&gt;




&lt;h1&gt;
  
  
  Real-Time Updates
&lt;/h1&gt;

&lt;p&gt;Suppose you're designing a chat application.&lt;/p&gt;

&lt;p&gt;How does the client know that a new message has arrived?&lt;/p&gt;

&lt;p&gt;There are several possibilities:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Polling
   ↓
"Do I have new messages?"

Long Polling
   ↓
"Tell me when something changes."

SSE
   ↓
Server → Client stream

WebSocket
   ↓
Persistent bidirectional connection

Push Notification
   ↓
Wake/notify the mobile application
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each approach has different implications for battery usage, latency, infrastructure complexity, and reliability.&lt;/p&gt;

&lt;p&gt;A strong interview answer explains &lt;strong&gt;why&lt;/strong&gt; you choose one.&lt;/p&gt;




&lt;h1&gt;
  
  
  Pagination
&lt;/h1&gt;

&lt;p&gt;Mobile applications rarely download unlimited data at once.&lt;/p&gt;

&lt;p&gt;A news feed containing 100,000 posts should not return all 100,000 records to the device.&lt;/p&gt;

&lt;p&gt;Common pagination strategies include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Limit/Offset&lt;/li&gt;
&lt;li&gt;Page-based pagination&lt;/li&gt;
&lt;li&gt;Keyset pagination&lt;/li&gt;
&lt;li&gt;Cursor-based pagination&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /posts?cursor=abc123&amp;amp;limit=20

        ↓

20 posts

        ↓

nextCursor = xyz789

        ↓

GET /posts?cursor=xyz789&amp;amp;limit=20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cursor-based pagination is often useful for feeds where data changes while the user is scrolling because it can provide more stable traversal than simple offsets.&lt;/p&gt;




&lt;h1&gt;
  
  
  API Integration
&lt;/h1&gt;

&lt;p&gt;Your mobile application needs an API layer that handles communication with the backend.&lt;/p&gt;

&lt;p&gt;On iOS, common tools include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;URLSession&lt;/li&gt;
&lt;li&gt;Alamofire&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On Android:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OkHttp&lt;/li&gt;
&lt;li&gt;Retrofit&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You'll also need serialization and deserialization.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JSON Response
     ↓
DTO
     ↓
Mapper
     ↓
Domain Model
     ↓
UI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keeping API DTOs separate from domain models can prevent backend API changes from leaking throughout the application.&lt;/p&gt;




&lt;h1&gt;
  
  
  Delta Updates
&lt;/h1&gt;

&lt;p&gt;Imagine your application already downloaded 10,000 messages yesterday.&lt;/p&gt;

&lt;p&gt;When the user opens the app today, downloading all 10,000 messages again is wasteful.&lt;/p&gt;

&lt;p&gt;Instead, the client can ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Give me only what changed since my last synchronization."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Last Sync
2026-09-01 10:00:00

        ↓

GET /messages?updated_after=2026-09-01T10:00:00

        ↓

Only changed records
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Delta updates can use mechanisms such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;timestamps&lt;/li&gt;
&lt;li&gt;sequence IDs&lt;/li&gt;
&lt;li&gt;ETags&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Last-Modified&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This reduces bandwidth, latency, and battery consumption.&lt;/p&gt;




&lt;h1&gt;
  
  
  Offline Support and Synchronization
&lt;/h1&gt;

&lt;p&gt;This is one of the areas that separates mobile system design from a simple API design exercise.&lt;/p&gt;

&lt;p&gt;A mobile device can lose connectivity at any time.&lt;/p&gt;

&lt;p&gt;Suppose a user edits a document while offline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User Edit
   ↓
Local Database
   ↓
Pending Sync Queue
   ↓
Network Available
   ↓
Upload Changes
   ↓
Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you need to answer:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens if the same document was modified on another device?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's a conflict-resolution problem.&lt;/p&gt;

&lt;p&gt;You should be prepared to discuss:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;conflict resolution&lt;/li&gt;
&lt;li&gt;retry queues&lt;/li&gt;
&lt;li&gt;background synchronization&lt;/li&gt;
&lt;li&gt;batched requests&lt;/li&gt;
&lt;li&gt;resumable uploads&lt;/li&gt;
&lt;li&gt;resumable downloads&lt;/li&gt;
&lt;li&gt;prefetching&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Offline-first design is fundamentally about treating the local device as an important part of the distributed system.&lt;/p&gt;




&lt;h1&gt;
  
  
  Caching
&lt;/h1&gt;

&lt;p&gt;Caching can dramatically improve perceived performance.&lt;/p&gt;

&lt;p&gt;A mobile application might have several cache layers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UI
 │
 ▼
Memory Cache
 │
 ▼
Disk Cache
 │
 ▼
Network
 │
 ▼
Backend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Common mechanisms include:&lt;/p&gt;

&lt;h3&gt;
  
  
  HTTP caching
&lt;/h3&gt;

&lt;p&gt;Using headers such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Cache-Control&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ETag&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Last-Modified&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Memory caching
&lt;/h3&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;NSCache&lt;/code&gt; on iOS&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;LruCache&lt;/code&gt; on Android&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disk caching
&lt;/h3&gt;

&lt;p&gt;Useful for larger or persistent data such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;images&lt;/li&gt;
&lt;li&gt;API responses&lt;/li&gt;
&lt;li&gt;downloaded content&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But caching introduces another problem:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;When does cached data become invalid?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is the cache invalidation problem.&lt;/p&gt;

&lt;p&gt;A strong system design answer should explain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;what you're caching&lt;/li&gt;
&lt;li&gt;where you're caching it&lt;/li&gt;
&lt;li&gt;how long it remains valid&lt;/li&gt;
&lt;li&gt;how it gets invalidated&lt;/li&gt;
&lt;li&gt;what happens when stale data is displayed&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Authentication
&lt;/h1&gt;

&lt;p&gt;Mobile applications commonly use several authentication mechanisms.&lt;/p&gt;

&lt;p&gt;You should understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;username/password authentication over HTTPS&lt;/li&gt;
&lt;li&gt;Sign in with Apple&lt;/li&gt;
&lt;li&gt;Google Sign-In&lt;/li&gt;
&lt;li&gt;OAuth&lt;/li&gt;
&lt;li&gt;OpenID Connect&lt;/li&gt;
&lt;li&gt;biometric authentication&lt;/li&gt;
&lt;li&gt;multi-factor authentication&lt;/li&gt;
&lt;li&gt;access tokens&lt;/li&gt;
&lt;li&gt;refresh tokens&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A typical token flow looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Login
  ↓
Authorization Server
  ↓
Access Token + Refresh Token
  ↓
Mobile App
  ↓
API Request + Access Token
  ↓
Backend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the access token expires:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;API Request
    ↓
401 Unauthorized
    ↓
Refresh Token
    ↓
New Access Token
    ↓
Retry Original Request
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Token storage is also important.&lt;/p&gt;

&lt;p&gt;Sensitive credentials should not simply be stored in an arbitrary plaintext file or database.&lt;/p&gt;




&lt;h1&gt;
  
  
  Retry Policies
&lt;/h1&gt;

&lt;p&gt;Networks fail.&lt;/p&gt;

&lt;p&gt;A request might fail because of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;temporary connectivity problems&lt;/li&gt;
&lt;li&gt;server overload&lt;/li&gt;
&lt;li&gt;timeout&lt;/li&gt;
&lt;li&gt;DNS issues&lt;/li&gt;
&lt;li&gt;rate limiting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Blindly retrying immediately can make the problem worse.&lt;/p&gt;

&lt;p&gt;Instead, applications often use strategies such as:&lt;/p&gt;

&lt;h3&gt;
  
  
  Exponential Backoff
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Attempt 1 → immediately
Attempt 2 → 1 second
Attempt 3 → 2 seconds
Attempt 4 → 4 seconds
Attempt 5 → 8 seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Jitter can be added to prevent many clients from retrying at exactly the same time.&lt;/p&gt;

&lt;p&gt;You should also understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;linear backoff&lt;/li&gt;
&lt;li&gt;circuit breakers&lt;/li&gt;
&lt;li&gt;retry-after responses&lt;/li&gt;
&lt;li&gt;retrying after token refresh&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key interview principle is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Retries should be deliberate, bounded, and aware of whether an operation is safe to repeat.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  API Evolution
&lt;/h1&gt;

&lt;p&gt;Mobile applications create a unique API compatibility problem.&lt;/p&gt;

&lt;p&gt;A backend can be updated today, but millions of users may still have an older version of the application installed.&lt;/p&gt;

&lt;p&gt;Therefore, your backend may need to support multiple client versions simultaneously.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    Backend API
                   /     |      \
                  /      |       \
             v1 Client  v2 Client  v3 Client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Good API evolution practices include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;adding fields without breaking old clients&lt;/li&gt;
&lt;li&gt;avoiding unnecessary breaking changes&lt;/li&gt;
&lt;li&gt;versioning APIs when necessary&lt;/li&gt;
&lt;li&gt;maintaining backward compatibility&lt;/li&gt;
&lt;li&gt;safely deprecating old fields&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is one reason mobile system design is closely connected to distributed systems.&lt;/p&gt;




&lt;h1&gt;
  
  
  CDN
&lt;/h1&gt;

&lt;p&gt;For applications serving large amounts of static or media content, a Content Delivery Network (CDN) can move content closer to users.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mobile App
    ↓
Origin Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mobile App
    ↓
Nearest CDN Edge
    ↓
Cache Hit → Content
    │
    └── Cache Miss
            ↓
       Origin Server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CDNs are especially useful for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;images&lt;/li&gt;
&lt;li&gt;videos&lt;/li&gt;
&lt;li&gt;static files&lt;/li&gt;
&lt;li&gt;application assets&lt;/li&gt;
&lt;li&gt;large downloads&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But you should still think about cache invalidation, TTLs, authentication, signed URLs, and regional distribution.&lt;/p&gt;




&lt;h1&gt;
  
  
  How to Use This Knowledge Map
&lt;/h1&gt;

&lt;p&gt;The goal isn't to memorize every technology listed above.&lt;/p&gt;

&lt;p&gt;Instead, use the map to identify your weak areas.&lt;/p&gt;

&lt;p&gt;Read through the topics and grade yourself.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mobile Domain              4/5
API Design                 3/5
Architecture               5/5
Data Storage               2/5
Performance                3/5
Security                   2/5
Observability              2/5
Advanced Topics            1/5
Interview Strategy         3/5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your preparation becomes much more focused.&lt;/p&gt;

&lt;p&gt;Instead of saying:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I need to study mobile system design."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I understand mobile architecture, but I need to improve offline synchronization, caching, and security."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's a much more actionable preparation plan.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Mid-Level Engineers Should Focus On
&lt;/h1&gt;

&lt;p&gt;If you're preparing for a mid-level mobile engineering position, focus first on the foundational concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mobile application lifecycle&lt;/li&gt;
&lt;li&gt;UI architecture&lt;/li&gt;
&lt;li&gt;threading and concurrency&lt;/li&gt;
&lt;li&gt;navigation&lt;/li&gt;
&lt;li&gt;networking&lt;/li&gt;
&lt;li&gt;API design&lt;/li&gt;
&lt;li&gt;pagination&lt;/li&gt;
&lt;li&gt;caching&lt;/li&gt;
&lt;li&gt;authentication&lt;/li&gt;
&lt;li&gt;offline support&lt;/li&gt;
&lt;li&gt;local storage&lt;/li&gt;
&lt;li&gt;performance&lt;/li&gt;
&lt;li&gt;basic security&lt;/li&gt;
&lt;li&gt;testing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don't need to master every advanced distributed-systems concept before starting mock interviews.&lt;/p&gt;

&lt;p&gt;Learn the fundamentals, then practice applying them.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Senior and Staff Engineers Should Add
&lt;/h1&gt;

&lt;p&gt;For senior and staff-level interviews, interviewers may expect deeper reasoning around:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;large-scale synchronization&lt;/li&gt;
&lt;li&gt;conflict resolution&lt;/li&gt;
&lt;li&gt;advanced caching&lt;/li&gt;
&lt;li&gt;offline-first architecture&lt;/li&gt;
&lt;li&gt;real-time systems&lt;/li&gt;
&lt;li&gt;observability&lt;/li&gt;
&lt;li&gt;privacy&lt;/li&gt;
&lt;li&gt;security architecture&lt;/li&gt;
&lt;li&gt;scalability&lt;/li&gt;
&lt;li&gt;multi-region systems&lt;/li&gt;
&lt;li&gt;reliability&lt;/li&gt;
&lt;li&gt;advanced performance optimization&lt;/li&gt;
&lt;li&gt;complex data consistency problems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The difference isn't simply knowing more technologies.&lt;/p&gt;

&lt;p&gt;It's being able to explain &lt;strong&gt;tradeoffs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Why did you choose WebSockets instead of polling?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;is a much more important question than:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Do you know WebSockets?"&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  How to Practice Mobile System Design Interviews
&lt;/h1&gt;

&lt;p&gt;Reading is only part of the preparation.&lt;/p&gt;

&lt;p&gt;You need to practice designing systems yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solve at Least Five Problems
&lt;/h2&gt;

&lt;p&gt;Choose different types of applications.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Design a News Feed&lt;/li&gt;
&lt;li&gt;Design a Chat Application&lt;/li&gt;
&lt;li&gt;Design a Ride-Sharing App&lt;/li&gt;
&lt;li&gt;Design a Video Streaming App&lt;/li&gt;
&lt;li&gt;Design an Offline Notes Application&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Don't immediately look at someone else's solution.&lt;/p&gt;

&lt;p&gt;Start with a blank page.&lt;/p&gt;




&lt;h2&gt;
  
  
  Use the Same Process Every Time
&lt;/h2&gt;

&lt;p&gt;A useful interview structure is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Clarify Requirements
          ↓
2. Define Core User Flows
          ↓
3. Design Mobile Architecture
          ↓
4. Design API / Networking
          ↓
5. Design Local Storage
          ↓
6. Discuss Caching &amp;amp; Offline
          ↓
7. Discuss Performance
          ↓
8. Discuss Security
          ↓
9. Discuss Failure Cases
          ↓
10. Explain Tradeoffs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives you a repeatable framework rather than trying to improvise every interview.&lt;/p&gt;




&lt;h1&gt;
  
  
  Do Mock Interviews
&lt;/h1&gt;

&lt;p&gt;Try to complete at least &lt;strong&gt;two mock interviews&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;One should happen near the beginning of your preparation.&lt;/p&gt;

&lt;p&gt;The second should happen closer to your actual interview.&lt;/p&gt;

&lt;p&gt;The goal isn't just to test whether you know the material.&lt;/p&gt;

&lt;p&gt;You want to discover whether you can &lt;strong&gt;communicate your design clearly under time pressure&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A candidate might know everything about caching but still struggle if they spend 25 minutes discussing UI architecture and have no time left for scalability or failure scenarios.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Most Important Skill: Connecting the Pieces
&lt;/h1&gt;

&lt;p&gt;The biggest mistake in mobile system design preparation is studying each topic independently.&lt;/p&gt;

&lt;p&gt;Knowing caching is useful.&lt;/p&gt;

&lt;p&gt;Knowing WebSockets is useful.&lt;/p&gt;

&lt;p&gt;Knowing Coroutines is useful.&lt;/p&gt;

&lt;p&gt;Knowing SQLite or Core Data is useful.&lt;/p&gt;

&lt;p&gt;But the interview asks you to combine them.&lt;/p&gt;

&lt;p&gt;Consider a chat application.&lt;/p&gt;

&lt;p&gt;You might need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                Chat Application
                       │
       ┌───────────────┼────────────────┐
       │               │                │
    WebSocket        Local DB         Push
       │               │                │
 Real-time          Offline           Background
 Messages           History           Notification
       │               │                │
       └───────────────┼────────────────┘
                       │
                  Sync Engine
                       │
                 Conflict Logic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the real skill.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;System design is about understanding how individual engineering concepts work together to solve a product problem.&lt;/strong&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Takeaway
&lt;/h1&gt;

&lt;p&gt;Mobile system design isn't a single technology.&lt;/p&gt;

&lt;p&gt;It's the intersection of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mobile platform knowledge&lt;/li&gt;
&lt;li&gt;software architecture&lt;/li&gt;
&lt;li&gt;networking&lt;/li&gt;
&lt;li&gt;distributed systems&lt;/li&gt;
&lt;li&gt;data storage&lt;/li&gt;
&lt;li&gt;performance engineering&lt;/li&gt;
&lt;li&gt;security&lt;/li&gt;
&lt;li&gt;reliability&lt;/li&gt;
&lt;li&gt;product requirements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don't need to learn everything at once.&lt;/p&gt;

&lt;p&gt;Start with the fundamentals.&lt;/p&gt;

&lt;p&gt;Identify your weak areas.&lt;/p&gt;

&lt;p&gt;Practice applying those concepts to real mobile products.&lt;/p&gt;

&lt;p&gt;Then gradually move into advanced topics and increasingly difficult system-design problems.&lt;/p&gt;

&lt;p&gt;The goal isn't to memorize a perfect architecture.&lt;/p&gt;

&lt;p&gt;The goal is to develop the ability to look at a problem and reason about:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;requirements → architecture → tradeoffs → failure modes → scalability → user experience.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's what makes someone strong at mobile system design interviews.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Complete Mobile System Design Roadmap
&lt;/h2&gt;

&lt;p&gt;This article covers the major concepts you need to understand, but mobile system design is a broad subject. If you want to follow the topics in a structured order, you can use the &lt;strong&gt;complete Mobile System Design roadmap on Algonur&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The roadmap brings the topics together so you can see what to learn first, what to study next, and how the different areas of mobile system design connect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;→ &lt;a href="https://www.algonur.com/#course/mobile-system-design/lesson/mobile-system-design%20" rel="noopener noreferrer"&gt;Explore the complete Mobile System Design roadmap on Algonur&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can use the roadmap alongside this article to identify gaps in your knowledge and build your preparation step by step.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>interview</category>
      <category>mobile</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>How to turn on charge only mode programatically if the mode if file transfer in android?</title>
      <dc:creator>Shakibaenur</dc:creator>
      <pubDate>Sun, 08 Oct 2023 07:20:23 +0000</pubDate>
      <link>https://dev.to/shakibaenur/how-to-turn-on-charge-only-mode-programatically-if-the-mode-if-file-transfer-in-android-56oe</link>
      <guid>https://dev.to/shakibaenur/how-to-turn-on-charge-only-mode-programatically-if-the-mode-if-file-transfer-in-android-56oe</guid>
      <description>&lt;p&gt;I will have to show this type of dialog if my device is connected to usb and I want to access the app. Here this dialog shows -Click to Charge Only will automatically set the USB protocol to Charge only mode and i can not access files from my phone&lt;/p&gt;

&lt;p&gt;Can Anyone help me to achieve this feature?&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdmm578cfldl142q6v4hy.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdmm578cfldl142q6v4hy.jpeg" alt=" " width="718" height="615"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have used to get device list but device list is empty. But still i dont thing this will solve my problem&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (entry in usbDeviceList.entries) {
            val usbDevice = entry.value

            // Check the USB device's connection mode
            val usbConfiguration = usbDevice.getConfiguration(0)
            val usbInterface = usbConfiguration.getInterface(0)
            val usbInterfaceClass = usbInterface.interfaceClass

            // Check if the interface class indicates MTP (Media Transfer Protocol)
            if (usbInterfaceClass == 6) {
                // The device is in MTP mode (File Transfer mode)
                // You can perform file transfer operations here
                Toast.makeText(applicationContext, "(File Transfer mode)", Toast.LENGTH_LONG).show()
            } else {
                // The device is not in MTP mode
                // Handle the mode accordingly
                Toast.makeText(applicationContext, "MTP mode", Toast.LENGTH_LONG).show()
            }
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Android — Drag and Drop</title>
      <dc:creator>Shakibaenur</dc:creator>
      <pubDate>Fri, 17 Feb 2023 17:21:00 +0000</pubDate>
      <link>https://dev.to/shakibaenur/android-drag-and-drop-3k3e</link>
      <guid>https://dev.to/shakibaenur/android-drag-and-drop-3k3e</guid>
      <description>&lt;p&gt;Today i want to talk about my one of the most favourite features in android development that is &lt;strong&gt;"Drag and Drop"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In modern user interfaces, drag and drop has become an essential interaction pattern for enabling users to move objects around a screen with a touch gesture.&lt;/p&gt;

&lt;p&gt;The drag and drop framework in Android Kotlin provides a simple and flexible way to implement drag and drop functionality in your app. It allows users to drag a view or item from one location to another by simply tapping and holding the item, and then dragging it to its desired destination. The drag and drop framework is based on three key components: the &lt;strong&gt;DragEvent&lt;/strong&gt;, the &lt;strong&gt;DragShadow&lt;/strong&gt;, and the &lt;strong&gt;ClipData object&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DragEvent:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The DragEvent class is responsible for managing the entire drag and drop lifecycle. It provides a set of constants that represent different states of the drag and drop operation. These states include &lt;strong&gt;ACTION_DRAG_STARTED&lt;/strong&gt;, &lt;strong&gt;ACTION_DRAG_ENTERED&lt;/strong&gt;, &lt;strong&gt;ACTION_DRAG_LOCATION&lt;/strong&gt;, &lt;strong&gt;ACTION_DRAG_EXITED&lt;/strong&gt;, &lt;strong&gt;ACTION_DROP&lt;/strong&gt;, and &lt;strong&gt;ACTION_DRAG_ENDED&lt;/strong&gt;. These states are used to identify when a drag operation is starting, when it's in progress, and when it's completed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DragShadow:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The DragShadow class is responsible for creating a visual representation of the item being dragged. It is an optional component that can be used to provide a custom visual representation of the item being dragged. It's also possible to use the default drag shadow, which is a simple opaque image of the view being dragged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ClipData:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;ClipData&lt;/strong&gt; class is responsible for storing the data associated with the item being dragged. This data can be anything that you want to associate with the item, such as text, images, or other types of data. You can use the &lt;strong&gt;ClipData.newPlainText()&lt;/strong&gt; method to create a new &lt;strong&gt;ClipData object&lt;/strong&gt; that contains plain text data, or you can create a custom ClipData object that contains any type of data.&lt;/p&gt;

&lt;p&gt;These were the fundamental parts. Now let's think about a Drag and Drop game you want to built for kids. To built this you must know about &lt;strong&gt;View.setOnTouchListener()&lt;/strong&gt; and &lt;strong&gt;View.OnDragEventListener()&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Note that i am just sharing the basic concept. Assume i want to match a shape. Let's call it &lt;strong&gt;"Match the Shape"&lt;/strong&gt;. I this application I have a triangle shaped object and want to match it with the shape. &lt;/p&gt;

&lt;p&gt;Now proceed of making this little application.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click on &lt;strong&gt;File&lt;/strong&gt;, then &lt;strong&gt;New&lt;/strong&gt; =&amp;gt; &lt;strong&gt;New Project&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;After that include the Kotlin support and click on next.&lt;/li&gt;
&lt;li&gt;Select the minimum SDK as per convenience and click the next button.&lt;/li&gt;
&lt;li&gt;Then select the &lt;strong&gt;Empty&lt;/strong&gt; activity =&amp;gt; &lt;strong&gt;next&lt;/strong&gt; =&amp;gt; &lt;strong&gt;finish&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;View Binding&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I have used view binding in this project. To enable view binding in a module, set the &lt;strong&gt;viewBinding&lt;/strong&gt; build option to true in the module-level &lt;strong&gt;build.gradle&lt;/strong&gt; file, as shown in the following example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;buildFeatures {
    viewBinding = true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;activity_main.xml file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the xml file we have two ImageView one is for showing the shape &lt;strong&gt;ivTriangle&lt;/strong&gt; and another one &lt;strong&gt;ivTriangleDrag&lt;/strong&gt; to drag it on the shape.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity"&amp;gt;

    &amp;lt;TextView
        android:id="@+id/tvTitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="12dp"
        android:text="Match the Shape"
        android:textAlignment="center"
        android:textSize="24sp" /&amp;gt;

    &amp;lt;ImageView
        android:id="@+id/ivTriangle"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_margin="12dp"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:src="@drawable/ic_triangle" /&amp;gt;

    &amp;lt;ImageView
        android:id="@+id/ivTriangleDrag"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_margin="12dp"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:src="@drawable/ic_triangle_drag" /&amp;gt;

&amp;lt;/LinearLayout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;MainActivity.kt&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will implement the &lt;strong&gt;onTouch&lt;/strong&gt; and &lt;strong&gt;onDrag&lt;/strong&gt; functions of &lt;strong&gt;View.OnTouchListener&lt;/strong&gt; and &lt;strong&gt;View.OnDragListener&lt;/strong&gt; correspondingly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MainActivity : AppCompatActivity(), View.OnTouchListener, View.OnDragListener{

..........
 override fun onTouch(v: View?, event: MotionEvent?): Boolean {
        ........
  }

 override fun onDrag(v: View?, event: DragEvent?): Boolean {
        .........
  }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here in &lt;strong&gt;onCreate&lt;/strong&gt; function we will initialise the &lt;strong&gt;setOnTouchListener&lt;/strong&gt; to &lt;strong&gt;ivTriangleDrag&lt;/strong&gt; and &lt;strong&gt;setOnDragListener&lt;/strong&gt; to &lt;strong&gt;ivTriangle&lt;/strong&gt;&amp;nbsp;. As we want to touch &lt;strong&gt;ivTriangleDrag&lt;/strong&gt; then drag it over &lt;strong&gt;ivTriangle&lt;/strong&gt; and drop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    mViewBinding = ActivityMainBinding.inflate(layoutInflater)
    setContentView(mViewBinding.root)

    mViewBinding.ivTriangleDrag.setOnTouchListener(this)
    mViewBinding.ivTriangle.setOnDragListener(this)

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can see the &lt;strong&gt;Motion.ACTION_DOWN&lt;/strong&gt; event of &lt;strong&gt;ivTriangleDrag&lt;/strong&gt; will trigger when we will touch it and drop it in the screen anywhere.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;override fun onTouch(v: View?, event: MotionEvent?): Boolean {
    return if (event!!.action == MotionEvent.ACTION_DOWN) {
        val data = ClipData.newPlainText("", "")
        val shadowBuilder = DragShadowBuilder(v)
        v?.startDragAndDrop(data, shadowBuilder, v, 0)
        true
    } else {
        false
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the onDrag function will trigger the DragEvent callbacks. Now when we will drop &lt;strong&gt;ivTriangleDrag&lt;/strong&gt; over &lt;strong&gt;ivTriangle&lt;/strong&gt; then &lt;strong&gt;ACTION_DROP&lt;/strong&gt; will trigger and as we wanted we will change the background &lt;strong&gt;ivTriangle&lt;/strong&gt; and will &lt;strong&gt;INVISIBLE&lt;/strong&gt; &lt;strong&gt;ivTriangleDrag&lt;/strong&gt; Imageview.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;override fun onDrag(v: View?, event: DragEvent?): Boolean {
    when (event?.action) {
        ACTION_DRAG_STARTED -&amp;gt; {
            Log.d(msg, "Action is DragEvent.ACTION_DRAG_STARTED");
        }
        ACTION_DRAG_ENTERED -&amp;gt; {
            Log.d(msg, "Action is DragEvent.ACTION_DRAG_ENTERED")
        }
        ACTION_DRAG_EXITED -&amp;gt; {
            Log.d(msg, "Action is DragEvent.ACTION_DRAG_EXITED")
        }
        ACTION_DRAG_LOCATION -&amp;gt; {
            Log.d(msg, "Action is DragEvent.ACTION_DRAG_LOCATION")
        }
        ACTION_DRAG_ENDED -&amp;gt; {
            Log.d(msg, "Action is DragEvent.ACTION_DRAG_ENDED")
        }
        ACTION_DROP -&amp;gt; {
            Log.d(msg, "ACTION_DROP event")
            mViewBinding.ivTriangle.setImageResource(R.drawable.ic_triangle_drag)
            mViewBinding.ivTriangleDrag.visibility = INVISIBLE
            Toast.makeText(this@MainActivity,"You have matched the shape!!",Toast.LENGTH_SHORT).show()
        }

    }
    return true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is a preview of "Match the Shape" App. And it's Ready.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuqzkml4j7sefsx0vxova.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuqzkml4j7sefsx0vxova.gif" alt="" width="222" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope this article helps you. To check out Full Code, here is the &lt;em&gt;&lt;strong&gt;&lt;a href="https://github.com/Shakibaenur/Drag_Drop.git" rel="noopener noreferrer"&gt;Repository&lt;/a&gt;&lt;/strong&gt;&lt;/em&gt;&amp;nbsp;.&lt;/p&gt;

&lt;p&gt;If you like the article do &lt;strong&gt;follow&lt;/strong&gt; me for more interesting topics on &lt;strong&gt;Android Development&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Happy Coding!&amp;nbsp;:)&lt;/p&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
