Ich habe ein Problem mit dem Speicherzugriffs -Framework, das keine Dateikopien korrekt nennt. Basisfileiname, also erhalte ich < /p>
ahoot.db3(1) anstelle von ahoot (1) .db3. Die Datei beim Speichern korrekt, aber ich weiß nicht, wie SAF die Datei kopiert, damit die Erweiterung gleich bleibt. < /p>
File destination = new File(DEST_PATH + File.separator + DB_NAME);
int num = 0;
while (destination.exists()) {
num++;
String[] alt = DB_NAME.split("\\.(?=[^\\.]+$)"); // CHANGE
destination = new File(DEST_PATH + File.separator + alt[0] + "(" + num + ")" + "." + alt[1]);
}
< /code>
Verwenden von URI < /p>
public void copyUriDatabase(InputStream in, Uri destinationUri) {
try {
OutputStream out = null;
out = this.getContentResolver().openOutputStream(destinationUri);
byte[] buffer = new byte[1024];
int read;
try {
while ((in.read(buffer)) > 0) {
if (out != null) {
out.write(buffer);
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
if (out != null) {
out.flush();
out.close();
}
in.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
< /code>
Die URI stammt von
URI destinationuri = resultdata.getData (); < /p>
Wie kann ich die SAF -Datei um Umbenennen von Kopien steuern [Duplikat] ⇐ Android
-
- Similar Topics
- Replies
- Views
- Last post