android - on application update ,need to migrate from database to sharedpreference -
in current project's previous version using database settings. think database overhead simple key value pairs decided utilize sharedpref that. problem how handle update functionality. not using database onupgrade not work.
i planing
arraylist<string> databases = new arraylist<string>(arrays.aslist(mcontext.databaselist())); if(databases.contains("dbname")){ copydatatosharedpref(); mcontext.deletedatabase("dbname"); } is there simple way handle this?
is there simple way handle this?
not isn't difficult. similar following...
when main / launcheractivity starts check sharedpreferences specific key, illustration - boolean "update_complete". if key doesn't exist, there 2 possibilities. first it's clean (new) install, sec it's update. if key does exist app has been updated , database info has been transferred sharedpreferences proceed run app. if key doesn't exist check see if database exists. if database doesn't exist new installation. in case setup sharedpreferences new installation. if key doesn't exist database does exist, transfer info database sharedpreferences, delete database set "update_complete" boolean sharedpreferences. i think covers it.
android updates
No comments:
Post a Comment