|
|
@ -150,14 +150,7 @@ public class EntityAttachment {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static File getFile(Context context, long id, String name) {
|
|
|
|
static File getFile(Context context, long id, String name) {
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
File dir = new File(getRoot(context), "attachments");
|
|
|
|
boolean external_storage = prefs.getBoolean("external_storage", false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File root = (external_storage
|
|
|
|
|
|
|
|
? context.getExternalFilesDir(null)
|
|
|
|
|
|
|
|
: context.getFilesDir());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File dir = new File(root, "attachments");
|
|
|
|
|
|
|
|
if (!dir.exists())
|
|
|
|
if (!dir.exists())
|
|
|
|
dir.mkdir();
|
|
|
|
dir.mkdir();
|
|
|
|
String filename = Long.toString(id);
|
|
|
|
String filename = Long.toString(id);
|
|
|
@ -168,6 +161,16 @@ public class EntityAttachment {
|
|
|
|
return new File(dir, filename);
|
|
|
|
return new File(dir, filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static File getRoot(Context context) {
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
|
|
|
|
boolean external_storage = prefs.getBoolean("external_storage", false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File root = (external_storage
|
|
|
|
|
|
|
|
? context.getExternalFilesDir(null)
|
|
|
|
|
|
|
|
: context.getFilesDir());
|
|
|
|
|
|
|
|
return root;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void copy(Context context, long oldid, long newid) {
|
|
|
|
static void copy(Context context, long oldid, long newid) {
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
|
|
|
|