On this page
Protecting User Data in AI Apps covers safeguards in the app itself. This article focuses on the lifecycle of data: where it goes, how long it stays, who can access it, and what you must disclose.
Privacy laws (GDPR, India's DPDP Act, CCPA and others) and provider terms differ and change. Consult qualified counsel for your app, and read your providers' current terms.
Map your AI data flows
Minimise what you send
- Send only the text needed for the task (retrieved chunks, not entire documents).
- Strip or mask identifiers (emails, phone numbers) when they're not needed.
- Prefer on-device processing for sensitive content. See Nano vs Cloud.
- Don't attach user profiles to prompts by default.
private val EMAIL = Regex("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}")
private val PHONE = Regex("(?:\\+?\\d[\\s-]?){10,13}")
fun redact(text: String): String =
text.replace(EMAIL, "[email]").replace(PHONE, "[phone]")Know your provider's terms
Providers differ on whether they retain prompts, for how long, whether they use data to improve models, and how this differs between free and paid tiers. Check your provider's current data governance terms (for example Firebase AI Logic and the Gemini API terms, or OpenAI's API data controls), choose settings and tiers that match your promises to users, and document the decision.
Log without content
data class AiCallEvent(
val feature: String, // "summarize"
val model: String, // "gemini-3.8-flash"
val source: String, // "cloud" | "on-device"
val inputTokens: Int?,
val outputTokens: Int?,
val latencyMs: Long,
val outcome: String, // "ok" | "blocked" | "error:429"
)
// Never log prompts, responses or file names by default.
// If you need samples for quality review, make it opt-in, anonymised and time-limited.Also check that crash reports don't capture prompt strings in exception messages or breadcrumbs.
Retention rules
| Data | Example rule |
|---|---|
| Chat history (device) | Kept until the user deletes; "clear all" available |
| Chat history (server sync) | Only if the user enables sync; deleted with the account |
| Backend request logs | Metadata only, 30 days |
| Quality review samples | Opt-in, anonymised, 90 days |
| Uploaded files | Deleted after processing |
These are examples. Set rules that fit your app and obligations, and implement them with automated deletion jobs.
User controls
- Clear disclosure before first use: what's processed, where, and why.
- A setting to disable cloud AI or AI features entirely.
- Delete history, and account deletion that covers AI data (Play requires an account deletion path for apps with accounts).
- Exclude sensitive local data from backups where appropriate.
Disclosures
- Play Data safety: declare data collected and shared, including data sent to AI providers and processed by SDKs.
- Privacy policy: describe AI processing, providers, retention and user rights.
- Keep disclosures in sync with code changes, and review on every AI feature launch.
Frequently asked questions
Is on-device AI automatically private?
Processing stays on device, but you may still store results, sync them or log them. Apply the same retention thinking.
Can I use user prompts to improve my product?
Only in line with your disclosures, user consent where required, and applicable law. Opt-in with anonymisation is the safer approach.
Conclusion
AI privacy is about the whole data lifecycle: map flows, minimise what's sent, understand provider retention, log metadata not content, set and automate retention rules, give users controls, and keep disclosures accurate.
Next step: defend against malicious inputs in Prompt Injection and Untrusted Input.
Official references
๐ฑ Apps built by Yunok Tech
Real Android apps on Google Play, free to download.
NotiVaultNotification history: recover dismissed notificationsGet it โธ
Walzi4K wallpapers for lock and home screenGet it โธ
Ready to build real Android applications?
Security is easiest to get right when it is part of how you build from the first screen. Strengthen the Android fundamentals that secure, privacy-respecting apps are built on.
Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.
Explore the Android course and take your next step as an Android developer.