Where to store application data on Android? [duplicate]
Asked Answered
I

4

5

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 situation 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.

Inventory answered 17/7, 2011 at 1:29 Comment(0)
P
6

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.

Porush answered 17/7, 2011 at 1:39 Comment(0)
H
3

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.

Humbert answered 17/7, 2011 at 2:48 Comment(3)
Where would the SQLite database be stored?Averment
@shailenTJ the Sqlite data will be stored under /data/data/packagename/databases/Wharf
That is correct. I found that folder path and it was full of app-specific data. By the way, is /data/data/* the only place where apps could store app-specific settings? I couldn't find any such folder on /mnt/Averment
J
0

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

Jagannath answered 17/7, 2011 at 1:39 Comment(2)
Yes, the method returns some directory, however app can't access it freely.Inventory
In what form it can't access? What is the error and what code do you use to access it?Jagannath
K
0
  • Keystore- For Sensitive data
  • SharedPreferences- Easily sharable and accessible data
  • SQLite- Lot of data with multiple relationships
Kweichow answered 7/5, 2022 at 17:53 Comment(1)
Your answer could be improved by explaining why each each of these locations suits its respective use case.Connivance

© 2022 - 2024 — McMap. All rights reserved.