DroidFish: Automatically create default directory structure on the SD card when starting the program.

This commit is contained in:
Peter Osterlund 2012-01-04 17:44:34 +00:00
parent 865eab1f9b
commit 869f45334e

View File

@ -179,6 +179,8 @@ public class DroidFish extends Activity implements GUIInterface {
String pgn = getPgnIntent(); String pgn = getPgnIntent();
createDirectories();
settings = PreferenceManager.getDefaultSharedPreferences(this); settings = PreferenceManager.getDefaultSharedPreferences(this);
settings.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() { settings.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() {
@Override @Override
@ -224,6 +226,15 @@ public class DroidFish extends Activity implements GUIInterface {
} }
} }
/** Create directory structure on SD card. */
private void createDirectories() {
File extDir = Environment.getExternalStorageDirectory();
String sep = File.separator;
new File(extDir + sep + bookDir).mkdirs();
new File(extDir + sep + pgnDir).mkdirs();
new File(extDir + sep + engineDir).mkdirs();
}
private String getPgnIntent() { private String getPgnIntent() {
String pgn = null; String pgn = null;
try { try {