1. Use autoInitialize() Pattern
Initialize the SDK in your Application class using theautoInitialize() method. This is the recommended approach used in the official demo app.
- Good
- Bad
- Initializes before Activity creation
- Prevents UI flashing with synchronous preload
- Fetches fresh data in background
- Works with offline mode fallback
2. Use applyStringbootTags() for XML Integration
Leverage XML tags for zero-code string integration instead of manual TextView updates.- Good
- Bad
- Declarative and maintainable
- Single call updates all tagged views
- Easier to refactor and audit
- Better performance than individual calls
3. Preload on Language Change
Always preload the cache when switching languages to avoid UI flickering.- Good
- Bad
- Prevents “flash of stale content”
- Instant string access after preload
- Better user experience
- Only loads most common strings
4. Use Flow for Reactive UI
Use Kotlin Flow to automatically update UI when language changes or sync completes.- Good
- Bad
- Reactive to language changes
- Updates on network sync completion
- Lifecycle-aware collection
- Perfect for dynamic content
5. Handle Missing Strings Gracefully
Always check for missing strings and provide fallback text.- Good
- Bad
- Check for
??key??pattern - Provide sensible default text
- Log warnings for debugging
- Improve user experience
6. Use withContext for FAQ Calls
Always fetch FAQs on a background thread to prevent blocking the main thread.- Good
- Bad
- IO operations off main thread
- Prevents ANR (Application Not Responding)
- Better responsiveness
- Proper coroutine context handling
7. Save Language Preferences
Persist user language preferences to restore on app restart.- Good
- Bad
- Respects user preferences
- Consistent experience across sessions
- Better user satisfaction
- Minimal storage overhead
8. Use Appropriate Cache Sizes
Configure cache size based on your app’s string count to balance memory and performance.- Good
- Bad
| String Count | Recommended Cache |
|---|---|
| 100-500 | 500 |
| 500-1000 | 1000 |
| 1000-5000 | 1500-2000 |
| 5000+ | 2000-5000 |
- Too small: Frequent DB queries (slow)
- Too large: Excessive memory use
- Right-sized: Balance performance and memory
- Monitor with
getCacheStats()
9. A/B Testing Best Practices
Use consistent device IDs and proper analytics integration for reliable A/B testing.- Good
- Bad
- Use persistent, installation-level device IDs (not session IDs)
- Set experiments as user properties in analytics (not events)
- Use the same device ID across all SDKs in your app
- Let SDK handle experiment assignment automatically
- Don’t manually assign users to variants
- Test experiment tracking in development before release
Summary
Following these 9 best practices ensures:- Fast app startup without UI flashing
- Responsive language switching
- Graceful offline functionality
- Optimal memory usage
- Better user experience
- Maintainable code structure
- Production-ready implementation
- Easier debugging and troubleshooting
- Reliable A/B testing with proper analytics tracking