I am developing an Android application and I need the save and load functions.
I want to save important data in a private application store using this function:
public static void save(Object file, String fileName, Context context) throws IOException, FileNotFoundException { FileOutputStream fos = context.openFileOutput(fileName, context.MODE_PRIVATE); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(file); oos.flush(); oos.close(); fos.close(); System.out.println(TAG + ": File saved successful!"); }
I also wrote a method for loading data. This works because I know the exact file name.
Now I need to do dynamic file saving with dynamic name generation. How can I list the files stored in the repository of attachment applications? So can I upload the exact file?
source share