开发者

android data storage questions

开发者 https://www.devze.com 2023-01-20 09:12 出处:网络
I would like to know if it is possible to for some application other my own to change a preference value of my application. Also are the preferences been kept by android when the phone is turned off?

I would like to know if it is possible to for some application other my own to change a preference value of my application. Also are the preferences been kept by android when the phone is turned off?

Is it safe to store some data(flags) on sharedpreferences in order to notify an activity for something?

When user clears the application data what exactly is erased, shared preferences data?

Is it preferred to use an internal private file to store secur开发者_开发知识库e data? Such as passwords?

Also I would like to be able to show a dialog when I detect a certain behavior, for this I have a monitoring service that has to notify the main activity about that. currently this is done through a callback method but I would like to maintain that state even if the application is killed or the phone reboots.

So I thought of setting a sharedpreference value (flag) and then on the oncreate method check if that flag exists. Also should I also check on the resume method?


Preferences (including SharedPreferences) are stored in files under your application's private data directory. No other application can read or write there, unless the phone has been rooted. This internal storage is flash-based and survives the phone being turned off... not much would work if it didn't. :)

As a general security principle you should never store a password. Secure systems store and compare password hashes, not the passwords themselves.

It's fine to store application state in preference data... personally I'd read it in onCreate() and thereafter write the value back to preferences either at the point it changes or in onPause().

0

精彩评论

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

关注公众号