sharedpreferences

What happens to my Android app and database when a user updates through Market Place?

ぃ、小莉子 提交于 2019-12-23 04:16:32
问题 Ok, I currently have an app on the MarketPlace and today I release its first update. Will the SQLite database used by my app be overwritten by the update, thus calling the onCreate once again? Or will it simply not touch the database? What happens to the SharedPreferences? Sorry for the seemingly simple questions, I've been googling for an hour now and haven't found anything on what happens to a package when the user updates the app. Does it totally wiped out and reinstalled? Dunno. Any help

Serialize or save PolylineOptions in Android

半腔热情 提交于 2019-12-23 02:39:28
问题 In my Android app I am already saving some strings to the SharedPreferences and serializing an ArrayList with Strings so this data is saved and can be used for future purposes. Even when the app is closed. A minute ago I discovered that I need to save my PolylineOptions for future use as well. PolylineOptions contain some coordinates to draw a line on my map with a color and width. I discovered that PolylineOptions aren't serializeable like Strings. Is there a way to 'save' my PolylineOptions

How to rename an existing shared preferences file in Android

那年仲夏 提交于 2019-12-23 00:51:12
问题 I am new to android. I have created SharedPreferences to store a playlist name and song names in the playlist. Now I have to rename the playlist. And another is: How do I delete the SharedPreferences file (i.e PlaylistName.xml ), when I delete the playlist? 回答1: At last, I am able to rename the sharedpreference file. For reference, in my context the code is: String fileName=etlistName.getText().toString(); File f=new File("/data/data/eywa.musicplayer/shared_prefs/"+PlayListName+".xml"); f

Broadcast receiver not affecting shared preferences in Android 4.0 (probably 3.1+)

。_饼干妹妹 提交于 2019-12-22 17:36:13
问题 So I have indeed searched thoroughly for an answer to my question; normally I can find answers pretty easily to pretty much anything. Anyway, basically I have an alarm manager set up which eventually sets a broadcast receiver. Inside the receiver, it decides which intent has been received, removes a shared preference, and then sets a notification that starts the activity. The problem is that on my phones with 4.0 the shared preference item is not successfully deleted, but on any previous

How to save image path using Shared Preferences

你说的曾经没有我的故事 提交于 2019-12-22 10:48:13
问题 I have an activity that opens another activity to get a camera gallery pic. The picture comes back to my original activity and rest in an imageView. That's working fine. How do I save the image so when the user comes back later, or kills to app the image is still there. I know I am supposed the use Shared Preferences to get the image path and not save the image itself but I just don't know how do that. Activity A private ImageView im1; private String selectedImagePath; private static final

SharedPreferences not working across Activities

 ̄綄美尐妖づ 提交于 2019-12-22 10:31:35
问题 I'm trying to save some filters/state in one activity, and then use that data in the next activity. I'm using SharedPreferences, but it isn't working as I'd expected it to. public class FilterActivity extends Activity { private static final String TAG = FilterActivity.class.getName(); EditText distanceEditor; @Override public void onPause() { super.onPause(); SharedPreferences preferences = getSharedPreferences(PreferenceKey.FILTER_PREFERENCES_NAME, MODE_WORLD_READABLE); String distance =

Prevent deletion of database or shared preference on clear app

流过昼夜 提交于 2019-12-22 09:37:50
问题 I want to prevent the deletion of shared preferences or database on clear such that it will clear only when the app is uninstalled. How can I keep shared preference safe on app. clear? 回答1: It is worth noting that there are three types of data clearing in Android, of which your application has no control over: Clear Data Clear Cache Clear Defaults Clear Data Clear data will clear everything under the application's working directory. This includes any shared preferences, databases and files

Android how to set default value of EditTextPreference from SharedPreference?

馋奶兔 提交于 2019-12-22 06:36:54
问题 This time in the same project I'm facing a slightly challenging issue where in settings.xml file in the res/xml folder: <EditTextPreference android:key="weight" android:title="@string/update_user_weight" android:persistent="true" android:dialogTitle="@string/update_user_weight" android:dialogMessage="@string/update_user_weight_message" android:defaultValue="" /> <EditTextPreference android:key="age" android:title="@string/update_user_age" android:persistent="true" android:dialogTitle="@string

Storing data in SharedPreferences accessible to all activities

早过忘川 提交于 2019-12-22 05:32:10
问题 I want to store and retrieve data that is accessible to all activities in my app using SharedPreferences. Is that possible? Up until now I have been doing it such that the data is stored for a particular activity. 回答1: Yes. SharePreferences do exactly this. In every activity you can this: SharedPreferences prefs = getSharedPreferences(ApplicationConstants.PREFERENCES, Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString(name, value); editor.commit(); And

Android check SharedPreferences for value type

…衆ロ難τιáo~ 提交于 2019-12-22 05:29:19
问题 I've got some key-value pairs in SharedPreferences , there are ints, floats, Strings, etc. Is there any way to check if a given key is of a specific type? EDIT I've studied the documentation and available methods. Sadly, it seems to me that i'd need to make it a "dirty" way, just trying every get method until i get value different than default set as parameter. this is the only one i figured out, but don't like it much... 回答1: You can iterate through all the entries in SharedPreferences and