v0.7.4b: refactored file handling to use String instead of File

This commit is contained in:
Evan Debenham
2019-08-01 21:52:31 -04:00
parent 7885da4b99
commit 785726f4f8
3 changed files with 38 additions and 71 deletions

View File

@@ -30,9 +30,7 @@ import android.os.ParcelFileDescriptor;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Rankings;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.journal.Journal;
import com.watabou.utils.FileUtils;
import java.io.File;
@@ -52,12 +50,29 @@ public class AndroidBackupHandler extends BackupAgent {
//does not backup runs in progress, to prevent cheating.
//store shared preferences
fullBackupFile(new File(getFilesDir().getParent() + "/shared_prefs/"+ ShatteredPixelDungeon.class.getCanonicalName() + ".xml"), data);
fullBackupFile(new File(getFilesDir().getParent() + "/shared_prefs/ShatteredPixelDungeon.xml"), data);
//store game data
fullBackupFile(FileUtils.getFile( getFilesDir(), Rankings.RANKINGS_FILE ), data);
fullBackupFile(FileUtils.getFile( getFilesDir(), Badges.BADGES_FILE ), data);
fullBackupFile(FileUtils.getFile( getFilesDir(), Journal.JOURNAL_FILE ), data);
File file = getFile( getFilesDir(), Rankings.RANKINGS_FILE );
if (file != null){
fullBackupFile( file , data);
}
file = getFile( getFilesDir(), Badges.BADGES_FILE );
if (file != null){
fullBackupFile( file , data);
}
file = getFile( getFilesDir(), Journal.JOURNAL_FILE );
if (file != null){
fullBackupFile( file , data);
}
}
private static File getFile( File base, String name ){
File file = new File(base, name);
if (!file.exists() || !file.isDirectory()){
return file;
}
return null;
}
}