Data synchronization between Android phone and tablet

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Data synchronization between Android phone and tablet
Medium
~3-5 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Data Sync Between Phone and Tablet (Android)

Synchronization between one user's devices is a task where most architectural solutions fail under unstable connection. User created a record on phone, tablet was offline for hours, then reconnected—and data either duplicates or one variant silently overwrites the other.

Architectural Choice: Push vs Pull

Pull sync—device periodically requests changes from server. Simpler to implement via WorkManager with PeriodicWorkRequest, but data is always slightly stale. Suitable for non-critical data: notes, settings.

Push sync—server notifies devices of changes via FCM (Firebase Cloud Messaging). Device receives data payload with event type and changed object ID, then re-fetches data. Don't send data itself in push—FCM payload limit is 4 KB and delivery is not guaranteed.

Hybrid—push as trigger, pull as data fetch mechanism. This is production standard.

Conflicts on Simultaneous Editing

The hardest part. Strategies:

Strategy Description When to use
Last Write Wins (LWW) Record with later updated_at wins Simple data without critical losses
Server Wins Local changes discarded on conflict Server-controlled data
Client Wins Local changes always applied User notes, drafts
Merge Field-level merging Documents with independent fields
CRDT Conflict-free Replicated Data Types Real-time collaboration

For most apps—LWW with metadata device_id and updated_at. Server stores latest version and timestamp, client on sync compares its updated_at with server's.

Implementation via Room + SyncAdapter or WorkManager

Room + WorkManager—modern approach without deprecated SyncAdapter:

@Entity(tableName = "notes")
data class Note(
    @PrimaryKey val id: String = UUID.randomUUID().toString(),
    val content: String,
    val updatedAt: Long = System.currentTimeMillis(),
    val deviceId: String = DeviceInfo.getDeviceId(),
    val syncStatus: SyncStatus = SyncStatus.PENDING
)

enum class SyncStatus { SYNCED, PENDING, CONFLICT }

syncStatus = PENDING—record created/modified locally, not yet sent to server.

class SyncWorker(context: Context, params: WorkerParameters) : CoroutineWorker(context, params) {

    override suspend fun doWork(): Result {
        return try {
            val pendingNotes = noteDao.getPendingNotes()

            pendingNotes.forEach { note ->
                val serverNote = api.getNote(note.id)
                when {
                    serverNote == null -> api.createNote(note)
                    serverNote.updatedAt > note.updatedAt -> {
                        // server is newer — update locally
                        noteDao.insert(serverNote.copy(syncStatus = SyncStatus.SYNCED))
                    }
                    else -> {
                        // local record is newer — send to server
                        api.updateNote(note)
                        noteDao.updateSyncStatus(note.id, SyncStatus.SYNCED)
                    }
                }
            }

            // fetch changes from server for period
            val serverChanges = api.getChangesSince(lastSyncTimestamp)
            noteDao.insertAll(serverChanges.map { it.copy(syncStatus = SyncStatus.SYNCED) })

            Result.success()
        } catch (e: IOException) {
            if (runAttemptCount < 3) Result.retry() else Result.failure()
        }
    }
}

Delta Sync

Downloading all data on every sync is inefficient. Server stores cursor or checkpoint: time of last successful sync for each device. Client on request sends its lastSyncTimestamp, server returns only changes after that moment.

// SharedPreferences or Room
val lastSyncTimestamp = prefs.getLong("last_sync_${deviceId}", 0L)
val changes = api.getChangesSince(lastSyncTimestamp)
prefs.edit().putLong("last_sync_${deviceId}", System.currentTimeMillis()).apply()

Adaptive UI: Phone vs Tablet

Sync is not only data. On tablet two-pane layout is common (list + details), on phone—one-pane. When implementing via SlidingPaneLayout or NavigationSuiteScaffold (Compose), list and detail ViewModels can be different or shared—depending on mode. When transitioning phone to tablet (foldables), UI must adapt without state loss via WindowSizeClass.

Common Mistakes

Race condition on concurrent sync. Two devices send changes simultaneously—without idempotent operations on server (PUT /notes/{id} instead of POST), we get duplication. Server should return 200 on repeat PUT with same data.

Deleted records not synced. Soft delete is mandatory—is_deleted = true instead of physical deletion. Otherwise tablet won't know phone deleted record and restore it on next sync.

Implementing sync from scratch: 1–2 weeks for basic LWW strategy with push notifications. Complex merge-strategy scenarios—from one month. Cost is calculated individually after requirements analysis.