Android : SharedPreferences data lifetime












0















For example if I do it once in my application :



sharedPref.edit().putString("com.blablabla.name_user","COCORICO").apply();


Can I find the data as long as the application is installed ?



String name_user = sharedPref.getString("com.blablabla.name_user", "");


Except if I reinstall the application or if I overwrite the data,



the data will never be lost, even several months later ?










share|improve this question



























    0















    For example if I do it once in my application :



    sharedPref.edit().putString("com.blablabla.name_user","COCORICO").apply();


    Can I find the data as long as the application is installed ?



    String name_user = sharedPref.getString("com.blablabla.name_user", "");


    Except if I reinstall the application or if I overwrite the data,



    the data will never be lost, even several months later ?










    share|improve this question

























      0












      0








      0








      For example if I do it once in my application :



      sharedPref.edit().putString("com.blablabla.name_user","COCORICO").apply();


      Can I find the data as long as the application is installed ?



      String name_user = sharedPref.getString("com.blablabla.name_user", "");


      Except if I reinstall the application or if I overwrite the data,



      the data will never be lost, even several months later ?










      share|improve this question














      For example if I do it once in my application :



      sharedPref.edit().putString("com.blablabla.name_user","COCORICO").apply();


      Can I find the data as long as the application is installed ?



      String name_user = sharedPref.getString("com.blablabla.name_user", "");


      Except if I reinstall the application or if I overwrite the data,



      the data will never be lost, even several months later ?







      android sharedpreferences






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 24 '18 at 20:02









      poulay1253poulay1253

      145




      145
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Why you think data should lost, unless you modified/deleted it?



          You can read more about shared perferences here: https://developer.android.com/training/data-storage/shared-preferences



          If you will uninstall application all shared perferences will be deleted. If it will be updated in correct way (signed with same keys) - not.






          share|improve this answer
























          • OK so it will not be deleted when we update the application ! cool ! thanks

            – poulay1253
            Nov 24 '18 at 20:09











          • Yes but you will need to use same keystore for all updates.

            – Andrey
            Nov 24 '18 at 20:13











          • yes i have the same keystore ! thank you Andrey

            – poulay1253
            Nov 24 '18 at 20:33



















          0














          No, it won't be deleted. It will be deleted only if:




          • user clears application data

          • user reinstalls the application


          • user manually deletes SP data



            SharedPreferences is made to save key values, such as settings, etc.
            You can find your SP file in /data/data/you.apk.package.name/shared_prefs/








          share|improve this answer
























          • thank you for the confirmation !

            – poulay1253
            Nov 24 '18 at 20:10











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53461902%2fandroid-sharedpreferences-data-lifetime%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Why you think data should lost, unless you modified/deleted it?



          You can read more about shared perferences here: https://developer.android.com/training/data-storage/shared-preferences



          If you will uninstall application all shared perferences will be deleted. If it will be updated in correct way (signed with same keys) - not.






          share|improve this answer
























          • OK so it will not be deleted when we update the application ! cool ! thanks

            – poulay1253
            Nov 24 '18 at 20:09











          • Yes but you will need to use same keystore for all updates.

            – Andrey
            Nov 24 '18 at 20:13











          • yes i have the same keystore ! thank you Andrey

            – poulay1253
            Nov 24 '18 at 20:33
















          0














          Why you think data should lost, unless you modified/deleted it?



          You can read more about shared perferences here: https://developer.android.com/training/data-storage/shared-preferences



          If you will uninstall application all shared perferences will be deleted. If it will be updated in correct way (signed with same keys) - not.






          share|improve this answer
























          • OK so it will not be deleted when we update the application ! cool ! thanks

            – poulay1253
            Nov 24 '18 at 20:09











          • Yes but you will need to use same keystore for all updates.

            – Andrey
            Nov 24 '18 at 20:13











          • yes i have the same keystore ! thank you Andrey

            – poulay1253
            Nov 24 '18 at 20:33














          0












          0








          0







          Why you think data should lost, unless you modified/deleted it?



          You can read more about shared perferences here: https://developer.android.com/training/data-storage/shared-preferences



          If you will uninstall application all shared perferences will be deleted. If it will be updated in correct way (signed with same keys) - not.






          share|improve this answer













          Why you think data should lost, unless you modified/deleted it?



          You can read more about shared perferences here: https://developer.android.com/training/data-storage/shared-preferences



          If you will uninstall application all shared perferences will be deleted. If it will be updated in correct way (signed with same keys) - not.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 24 '18 at 20:06









          AndreyAndrey

          1,64432146




          1,64432146













          • OK so it will not be deleted when we update the application ! cool ! thanks

            – poulay1253
            Nov 24 '18 at 20:09











          • Yes but you will need to use same keystore for all updates.

            – Andrey
            Nov 24 '18 at 20:13











          • yes i have the same keystore ! thank you Andrey

            – poulay1253
            Nov 24 '18 at 20:33



















          • OK so it will not be deleted when we update the application ! cool ! thanks

            – poulay1253
            Nov 24 '18 at 20:09











          • Yes but you will need to use same keystore for all updates.

            – Andrey
            Nov 24 '18 at 20:13











          • yes i have the same keystore ! thank you Andrey

            – poulay1253
            Nov 24 '18 at 20:33

















          OK so it will not be deleted when we update the application ! cool ! thanks

          – poulay1253
          Nov 24 '18 at 20:09





          OK so it will not be deleted when we update the application ! cool ! thanks

          – poulay1253
          Nov 24 '18 at 20:09













          Yes but you will need to use same keystore for all updates.

          – Andrey
          Nov 24 '18 at 20:13





          Yes but you will need to use same keystore for all updates.

          – Andrey
          Nov 24 '18 at 20:13













          yes i have the same keystore ! thank you Andrey

          – poulay1253
          Nov 24 '18 at 20:33





          yes i have the same keystore ! thank you Andrey

          – poulay1253
          Nov 24 '18 at 20:33













          0














          No, it won't be deleted. It will be deleted only if:




          • user clears application data

          • user reinstalls the application


          • user manually deletes SP data



            SharedPreferences is made to save key values, such as settings, etc.
            You can find your SP file in /data/data/you.apk.package.name/shared_prefs/








          share|improve this answer
























          • thank you for the confirmation !

            – poulay1253
            Nov 24 '18 at 20:10
















          0














          No, it won't be deleted. It will be deleted only if:




          • user clears application data

          • user reinstalls the application


          • user manually deletes SP data



            SharedPreferences is made to save key values, such as settings, etc.
            You can find your SP file in /data/data/you.apk.package.name/shared_prefs/








          share|improve this answer
























          • thank you for the confirmation !

            – poulay1253
            Nov 24 '18 at 20:10














          0












          0








          0







          No, it won't be deleted. It will be deleted only if:




          • user clears application data

          • user reinstalls the application


          • user manually deletes SP data



            SharedPreferences is made to save key values, such as settings, etc.
            You can find your SP file in /data/data/you.apk.package.name/shared_prefs/








          share|improve this answer













          No, it won't be deleted. It will be deleted only if:




          • user clears application data

          • user reinstalls the application


          • user manually deletes SP data



            SharedPreferences is made to save key values, such as settings, etc.
            You can find your SP file in /data/data/you.apk.package.name/shared_prefs/









          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 24 '18 at 20:06









          DominDomin

          457114




          457114













          • thank you for the confirmation !

            – poulay1253
            Nov 24 '18 at 20:10



















          • thank you for the confirmation !

            – poulay1253
            Nov 24 '18 at 20:10

















          thank you for the confirmation !

          – poulay1253
          Nov 24 '18 at 20:10





          thank you for the confirmation !

          – poulay1253
          Nov 24 '18 at 20:10


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53461902%2fandroid-sharedpreferences-data-lifetime%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Wiesbaden

          Marschland

          Dieringhausen