Because of the number of values, individual storage and deletion is not enough, so write a simple array-format write and delete operations.
/*** used to store the corresponding string type *@paramContext Contextual Object *@paramkey array of keys stored *@paramvalues stored in the value array*/ Public Static voidPutstringarray (Context context,string[] key,string[] values) { for(inti = 0; i < key.length; i++) { if(sharedpreferences==NULL) {sharedpreferences=context.getsharedpreferences ("config", context.mode_private); } sharedpreferences.edit (). putstring (Key[i], values[i]). commit (); } } /*** used to store the corresponding bool type *@paramContext Contextual Object *@paramkey array of keys stored *@paramvalues stored in the value array*/ Public Static voidPutboolarray (Context context,string[] key,boolean[] values) { for(inti = 0; i < key.length; i++) { if(sharedpreferences==NULL) {sharedpreferences=context.getsharedpreferences ("config", context.mode_private); } sharedpreferences.edit (). Putboolean (Key[i], values[i]). commit (); } } /*** Removes the specified node from the SP (removed by array) *@paramContext Environment *@paramkey requires removing the name of the node*/ Public Static voidRemovearray (context context, string[] key) { for(inti = 0; i < key.length; i++) { if(sharedpreferences==NULL) {sharedpreferences= context.getsharedpreferences ("config", context.mode_private); } sharedpreferences.edit (). Remove (Key[i]). commit (); } }
About sharedpreferences writing and deleting array data