开发者

Where to store application data on Android?

I use to use user.home + app_name directory under Linux and Windows. However directory given me by Android for user.home has no right to write. So what is common practice of storing application data? My situ开发者_StackOverflow中文版ation even more complicated. The data I need to store belong not to Android application, they belong to web application deployed on Android device, so suggestion using standard Android way may not work for me.


Well, there are many ways to store data in Adroid: http://developer.android.com/guide/topics/data/data-storage.html

If you are running a web application in a Android then you need to use data storage of web apps: http://diveintohtml5.ep.io/storage.html .

If you still want to keep the idea of filesystem access through web app, maybe this tutorial may help you: http://www.vogella.de/articles/AndroidFileSystem/article.html - mind the permissions.

Although, if you need to store data in the Android system you should choose to build an android app instead of use the web app to control the local data storage. You can get data from your web app using a URL Connection (http://developer.android.com/reference/java/net/URLConnection.html) and manage the storage through the Android app.


You can store application data in three ways:

  1. SharedPreferences
  2. SQLite Database
  3. file

All these files are stored under the /data/data/packagename/ directory.


You can use context getFilesDir() method. But check this article for more details.


  • Keystore- For Sensitive data
  • SharedPreferences- Easily sharable and accessible data
  • SQLite- Lot of data with multiple relationships
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜