Skip to content

Commit

Permalink
fix #1343
Browse files Browse the repository at this point in the history
  • Loading branch information
gdlbo committed Feb 17, 2024
1 parent b5ae266 commit e19ed88
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/src/main/java/ru/vtosters/lite/utils/VKAccountDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,22 @@ public static void saveData() {
LifecycleUtils.getCurrentActivity().requestPermissions(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 228);
}

var db = getDatabase().getReadableDatabase();
var dateFormat = new SimpleDateFormat("yyyy-MM-dd.HH-mm-ss", Locale.getDefault());
var dir = new File(getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS), "/VTLBackups/");
var file = new File(dir, "saved_accounts_" + dateFormat.format(new Date()) + ".vtl");
SQLiteDatabase db = getDatabase().getReadableDatabase();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd.HH-mm-ss", Locale.getDefault());
File dir = new File(getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS), "/VTLBackups/");
File file = new File(dir, "saved_accounts_" + dateFormat.format(new Date()) + ".vtl");

try (InputStream inputStream = new FileInputStream(db.getPath())) {
dir.mkdirs();
if (!dir.exists()) {
dir.mkdirs();
}

FileOutputStream outputStream = new FileOutputStream(file);
byte[] buff = new byte[1024];
int read;
while ((read = inputStream.read(buff, 0, buff.length)) > 0)
while ((read = inputStream.read(buff, 0, buff.length)) > 0) {
outputStream.write(buff, 0, read);
}
inputStream.close();
outputStream.close();

Expand Down

0 comments on commit e19ed88

Please sign in to comment.