Quantcast
Channel: xda-developers - Android Software and Hacking General [Developers Only]
Viewing all articles
Browse latest Browse all 3614

How to make all information stay after app store update?

$
0
0
I just released my first update for my app, and apparently it wiped all data from each person's app as if it was a fresh install. There are list objects primarily that are stored with a FileInputStream as shown in the code and the settings are stored with SharedPreferences. Does anyone know how to make it where each time I update, these don't dissappear? Thanks!

Code:

public ObjectStorage readListFromFile()
    {
            ObjectStorage temp = null;
            String filename = "storefileobj";
        FileInputStream fis;
                try {
                        fis = getActivity().openFileInput(filename);
                        ObjectInputStream is = new ObjectInputStream(fis);
                temp = (ObjectStorage) is.readObject();
                is.close();
                } catch (FileNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (StreamCorruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (ClassNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
               
                return temp;
    }
   
   
    public void updateStorage()
    {
           
            String filename = "storefileobj";
        FileOutputStream fos;
                try {
                        fos = getActivity().openFileOutput(filename, Context.MODE_PRIVATE);
                        ObjectOutputStream os = new ObjectOutputStream(fos);
                os.writeObject(mainObjectList);
                os.close();
                } catch (FileNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
           
    }


Viewing all articles
Browse latest Browse all 3614

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>