Best Practices for Handling Android User Data

[By Nick Kralevich, an engineer on the Android Security Team]

As the use of mobile applications grows, people are paying more attention to how these applications use their data. While the Android platform contains extensive permissions designed to protect users, application developers are ultimately responsible for how they handle users’ information. It’s important for developers to understand the code they include, and consider the permissions they request, as mishandling these issues can result in users perceiving a violation of trust.

Maintaining a healthy and trustworthy ecosystem is in every Android developer’s best interest.

Here are a few tips for writing trustworthy Android applications:

  • Maintain a privacy policy
  • Minimize permissions
  • Give your users a choice regarding data collection
  • Don’t collect unnecessary information
  • Don’t send data off the device
  • ... but if you have to, use encryption and data minimization
  • Don’t use code you don’t understand
  • Don’t log device or user specific information.

** Maintain a privacy policy**

Trustworthy applications are up-front about the data they collect and the reasons for collecting it. Users are generally happy to share information via such apps if they believe they will personally benefit. A clear and concise privacy policy, with details about the type of information collected and how it’s used, goes a long way towards generating trust and goodwill. You can link users to your privacy policy right from your app's Google Play listing — visit the Developer Console to add the link.

** Minimize permissions**

Android is unique among mobile operating systems for its simple, straightforward, operating-system-enforced permission model. All Android applications must declare the permissions they require, and users must approve these permissions before the application is installed. Users tend to distrust applications that require excessive permissions.

For example, a user installing the tic-tac-toe game at left might reasonably wonder why it needs to take pictures.

** Give your users a choice regarding data collection**

It’s called the paradox of privacy [PDF, 890K]. Users are often happy to share their information, but they want control over that sharing. Trustworthy applications give users control over their information. For example, the Android Browser has privacy settings which enable users to control how their information is shared.

** Don’t collect unnecessary information**

Trustworthy applications limit the kinds of data they collect. Collecting unnecessary information, especially if you never use it, just invites suspicion. When in doubt, don’t collect it.

** Don’t send data off the device**

If you have to handle user data, ensure that the data remains on the device whenever possible. Users are comforted knowing that their private information strictly resides in the phone. Sending data outside the phone, even if done for the user’s benefit, tends to draw suspicion.

** ... but if you have to, use encryption and data minimization**

Sometimes, the collection of data is necessary. In that case, applications need to ensure that it is handled safely. A privacy policy will avoid leading to surprised and irritated users; in some cases, it may be advisable to prompt the user before transmitting data off-device.

First, minimize the amount of data you collect. Do you really need the user’s full phone number, or would the area code be sufficient? Can you use a one-way cryptographic hash function on the data before sending it to the server to help protect the user’s confidential information?

Second, encryption is critical to the safe handling of user data. Phones often operate on untrusted networks where attackers can sniff confidential traffic. Encrypting data in transit is a critical part of protecting user information.

Finally, when communicating with a server over HTTP, it’s a good idea to avoid encoding user information in a URL that is used with HTTP GET; rather, POST it in a message body. While using POST doesn’t guarantee that your information won’t be sniffed, putting it in the URL increases the likelihood that it will be automatically logged; out of the box, most web server software logs all the URLs that are received.


** A case study: User Favorites**

Suppose you want your app to maintain a list of “favorites” for each of your users, without going through a full registration process. In theory, you could do this by sending your server some combination of their phone number, device ID, or SIM ID. But why take the chance of worrying people about privacy issues; why not send a one-way hashed signature of whatever the identifying information is? Or even better, create a random unique id and store it on the phone, and use this unique id as the registration key for your application.

In the end, you’ll will still be able to retrieve their favorites, but you won’t need to send or store anything sensitive.

** Don’t use code you don’t understand**

In the open-source Android environment, it’s common (and good) practice to rely heavily on other people’s code, in the form of libraries and frameworks. But if that code is handling your users’ information inappropriately, it’s your problem. So make a point of checking code before you rely on it.

** Don’t log user or device specific information**

Application developers should be careful about on-device logs. Android makes it easy to write to the phone’s log, and anyone who has looked at “l(fā)ogcat” output knows that it is full of important but seemingly random debugging information from many applications. In Android, logs are a shared resource, and are available to an application with the READ_LOGS permission (only with user consent, of course!). Even though the phone log data is temporary and erased on reboot, inappropriate logging of user information could inadvertently leak user data to other applications.

原文地址

Best Practices for Handling Android User Data

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市宇攻,隨后出現(xiàn)的幾起案子牍白,更是在濱河造成了極大的恐慌净宵,老刑警劉巖边坤,帶你破解...
    沈念sama閱讀 206,968評(píng)論 6 482
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異撩穿,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)霍弹,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,601評(píng)論 2 382
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來娃弓,“玉大人典格,你說我怎么就攤上這事√ù裕” “怎么了耍缴?”我有些...
    開封第一講書人閱讀 153,220評(píng)論 0 344
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)挽霉。 經(jīng)常有香客問我防嗡,道長(zhǎng),這世上最難降的妖魔是什么侠坎? 我笑而不...
    開封第一講書人閱讀 55,416評(píng)論 1 279
  • 正文 為了忘掉前任蚁趁,我火速辦了婚禮,結(jié)果婚禮上实胸,老公的妹妹穿的比我還像新娘他嫡。我一直安慰自己,他們只是感情好童芹,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,425評(píng)論 5 374
  • 文/花漫 我一把揭開白布涮瞻。 她就那樣靜靜地躺著,像睡著了一般假褪。 火紅的嫁衣襯著肌膚如雪署咽。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,144評(píng)論 1 285
  • 那天生音,我揣著相機(jī)與錄音宁否,去河邊找鬼。 笑死缀遍,一個(gè)胖子當(dāng)著我的面吹牛慕匠,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播域醇,決...
    沈念sama閱讀 38,432評(píng)論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼台谊,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了譬挚?” 一聲冷哼從身側(cè)響起锅铅,我...
    開封第一講書人閱讀 37,088評(píng)論 0 261
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎减宣,沒想到半個(gè)月后盐须,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 43,586評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡漆腌,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,028評(píng)論 2 325
  • 正文 我和宋清朗相戀三年贼邓,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了阶冈。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,137評(píng)論 1 334
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡塑径,死狀恐怖女坑,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情晓勇,我是刑警寧澤堂飞,帶...
    沈念sama閱讀 33,783評(píng)論 4 324
  • 正文 年R本政府宣布,位于F島的核電站绑咱,受9級(jí)特大地震影響绰筛,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜描融,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,343評(píng)論 3 307
  • 文/蒙蒙 一铝噩、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧窿克,春花似錦骏庸、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,333評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至只损,卻和暖如春一姿,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背跃惫。 一陣腳步聲響...
    開封第一講書人閱讀 31,559評(píng)論 1 262
  • 我被黑心中介騙來泰國(guó)打工叮叹, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人爆存。 一個(gè)月前我還...
    沈念sama閱讀 45,595評(píng)論 2 355
  • 正文 我出身青樓蛉顽,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親先较。 傳聞我的和親對(duì)象是個(gè)殘疾皇子携冤,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,901評(píng)論 2 345

推薦閱讀更多精彩內(nèi)容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的閱讀 13,433評(píng)論 5 6
  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,399評(píng)論 0 23
  • 第一次畫畫 等素描書回來堅(jiān)持兩三個(gè)月素描 等開學(xué)來了入手水彩或者彩鉛
    芥末和芒果閱讀 201評(píng)論 0 1
  • 霓虹色的天橋下 一人醉成一堆麻 夜風(fēng)帶走了微涼的話 說著他想她 不過是普通尋常一幅畫 奈何你卻 矗立在燈火闌珊下 ...
    二號(hào)線_6748閱讀 176評(píng)論 0 0
  • 邁出家門讀書的那天起,生活好像九曲溪一樣闲勺,風(fēng)景無限噪叙。 在那個(gè)第一次走出家門,聽到思鄉(xiāng)曲還會(huì)流淚的年代...
    鳥飛過閱讀 257評(píng)論 0 0