Skip to content

Export to public directory (Fix #443, Fix #440) #451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/src/main/java/net/osmtracker/activity/About.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
Expand Down Expand Up @@ -76,7 +77,7 @@ public void onClick(View view) {

File dbFile = getDatabasePath(DatabaseHelper.DB_NAME);
File targetFolder = new File(
view.getContext().getExternalFilesDir(null),
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS),
//Environment.getExternalStorageDirectory(),
PreferenceManager.getDefaultSharedPreferences(About.this).getString(
OSMTracker.Preferences.KEY_STORAGE_DIR,
Expand Down Expand Up @@ -128,10 +129,17 @@ public ProgressDialog getExportDbProgressDialog() {

private String getDebugInfo() {
File externalStorageDir = this.getExternalFilesDir(null);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
String exportDirectoryNameInPreferences = preferences.getString(
OSMTracker.Preferences.KEY_STORAGE_DIR, OSMTracker.Preferences.VAL_STORAGE_DIR);
File baseExportDirectory = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS),
exportDirectoryNameInPreferences);
return "External Storage Directory: '" + externalStorageDir + "'\n"
+ "External Storage State: '" + Environment.getExternalStorageState() + "'\n"
+ "Can write to external storage: "
+ Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) + "\n";
+ Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) + "\n"
+ "Export External Public Storage Directory: '"
+ baseExportDirectory + "'\n";
}

}
2 changes: 1 addition & 1 deletion app/src/main/java/net/osmtracker/db/DataHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public static File getTrackDirectory(long trackId, Context context) {
File _return = null;

String trackStorageDirectory = context.getExternalFilesDir(null)
+ "/osmtracker/track" + trackId;
+ OSMTracker.Preferences.VAL_STORAGE_DIR + File.separator + "track" + trackId;

_return = new File(trackStorageDirectory);
return _return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public File getBaseExportDirectory(SharedPreferences prefs) throws ExportTrackEx
OSMTracker.Preferences.KEY_STORAGE_DIR, OSMTracker.Preferences.VAL_STORAGE_DIR);
Log.d(TAG,"exportDirectoryNameInPreferences: " + exportDirectoryNameInPreferences);

File baseExportDirectory = new File(context.getExternalFilesDir(null),
File baseExportDirectory = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS),
exportDirectoryNameInPreferences);

if(! baseExportDirectory.exists()){
Expand Down