Prepare storing message texts on external storage

This commit is contained in:
M66B
2022-11-08 11:31:19 +01:00
parent 7f5fa181d3
commit 119d30e6fb
2 changed files with 43 additions and 6 deletions

View File

@@ -577,11 +577,21 @@ public class EntityMessage implements Serializable {
}
static File getFile(Context context, Long id) {
File root = new File(context.getFilesDir(), "messages");
File root = Helper.ensureExists(new File(getRoot(context), "messages"));
File dir = Helper.ensureExists(new File(root, "D" + (id / 1000)));
return new File(dir, id.toString());
}
static File getRoot(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean external_storage = prefs.getBoolean("external_storage_message", false);
File root = (external_storage
? Helper.getExternalFilesDir(context)
: context.getFilesDir());
return root;
}
static void convert(Context context) {
File root = new File(context.getFilesDir(), "messages");
List<File> files = Helper.listFiles(root);