Array/Data Storage Options

后端 未结 3 602
梦如初夏
梦如初夏 2021-01-26 08:51

I am new to android and trying to develop my first app. In my app, I have a listview activity that lists a group of stores. When the app users (anyone who downloaded the app)

相关标签:
3条回答
  • 2021-01-26 09:28

    I would write the values to file using an ObjectOutputStream:

        public static void saveArray(String filename, String[] array) {
        try {
            FileOutputStream fos = openFileOutput(filename, Context.MODE_PRIVATE);
            ObjectOutputStream out = new ObjectOutputStream(fos);
            out.writeObject(array);
            out.flush();
            out.close();
        } catch (IOException e) {}
    }
    

    Then edit the above to save word counts as an int (or short) array.

    0 讨论(0)
  • 2021-01-26 09:33

    Use SQLite database to store your Store name and its count value. With its use, you can enhance your app's storage possibilities up to full extent.

    0 讨论(0)
  • 2021-01-26 09:34

    You could add store-count as key-value pairs to SharedPreferences

    http://developer.android.com/guide/topics/data/data-storage.html#pref

    It's a lightweight storage and pretty handy for stuff like this.

    0 讨论(0)
提交回复
热议问题