在内部存储中查找已保存的Json文件

时间:2017-11-29 14:36:55

标签: java android json arraylist gson

在将应用程序与Gson库一起使用时,我将几个ArrayLists保存到用户的内部存储中。由于我没有找到任何关于此的内容,我想知道是否有办法让我在我的Android手机内部存储中找到这些已保存的列表作为文件并查看它们。在.txt表示?

写入内部存储空间

public static void Write(ArrayList<Integer> icons, ArrayList<Integer> cardArts, ArrayList<String> cardNameAndDescription,
                         ArrayList<String> leaderSkills, ArrayList<String> superAttackNames, ArrayList<String> superAttackDesc,
                         ArrayList<String> passiveSkillNames, ArrayList<String> passiveSkillDesc, Context context) {

    SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = appPrefs.edit();
    Gson gson = new Gson();
    String iconsJson = gson.toJson(icons);
    String cardArtsJson = gson.toJson(cardArts);
    String cardNameAndDescriptionJson = gson.toJson(cardNameAndDescription);
    String leaderSkillsJson = gson.toJson(leaderSkills);
    String superAttackNamesJson = gson.toJson(superAttackNames);
    String superAttackDescJson = gson.toJson(superAttackDesc);
    String passiveSkillNamesJson = gson.toJson(passiveSkillNames);
    String passiveSkillDescJson = gson.toJson(passiveSkillDesc);
    editor.putString("Icons",iconsJson);
    editor.putString("CardArt",cardArtsJson);
    editor.putString("CardNameAndDesc",cardNameAndDescriptionJson);
    editor.putString("LeaderSkills",leaderSkillsJson);
    editor.putString("SANames",superAttackNamesJson);
    editor.putString("SADescs",superAttackDescJson);
    editor.putString("PassiveSkillNames",passiveSkillNamesJson);
    editor.putString("PassiveSkillDesc",passiveSkillDescJson);
    editor.apply();
    editor.commit();
    Log.d("WriteData","Data written successfully!");
}

0 个答案:

没有答案