There are various ways of storing and retrieving static data in Android, such as saving in file, using preferences, XML parsing and database.
my first question is which of each is faster (to read and write data)?
and second is which of each has the best security (for example, file method is not secure because if user root his phone, the file is accessible by开发者_如何学Python him or other softwares)?
Thanks
My opinion would be that anything stored on the device is never truly secure so the only real secure option is to host the data in your own database either through your own server or a web host.
It's pretty easy to get Android talking to web services and there are tons of examples around the internet with a little Googling. (Look for 'android web service', etc.)
If you have to store the data locally on the devices, I would say that using a local database would likely be the most secure option, although I'm definitely no expert in this area.
As for speed, local access will likely be faster than remote access simply due to network latency. However, If you choose to do network access, I would recommend utilizing JSON. Here's a great article related to Android/Services/JSON: http://www.josecgomez.com/2010/04/30/android-accessing-restfull-web-services-using-json/
精彩评论