22
33import android .content .Context ;
44import android .content .SharedPreferences ;
5+ import android .util .Log ;
56
67import java .io .FileInputStream ;
78import java .io .FileNotFoundException ;
1314
1415public class PersistenceManager {
1516
16- private static final String fileID = "at.connyduck.pixelwallpaper save file " ;
17+ private static final String fileID = "at.connyduck.pixelwallpaper. save" ;
1718 private static final String preferenceID = "at.connyduck.pixelwallpaper prefs" ;
1819
1920 private Context context ;
@@ -45,6 +46,7 @@ public boolean load() {
4546 fis = context .openFileInput (fileID );
4647 } catch (FileNotFoundException e ) {
4748 //first time load
49+ Log .i ("PersistenceManager" , Log .getStackTraceString (e ));
4850 return false ;
4951 }
5052
@@ -58,11 +60,10 @@ public boolean load() {
5860 i .close ();
5961 fis .close ();
6062
61- } catch (IOException e ) {
63+ } catch (IOException | ClassNotFoundException e ) {
64+ Log .w ("PersistenceManager" , Log .getStackTraceString (e ));
6265 return false ;
63- } catch (ClassNotFoundException e ) {
64- return false ;
65- }
66+ }
6667 }
6768
6869 SharedPreferences pref = context .getSharedPreferences (preferenceID , 0 );
@@ -86,7 +87,7 @@ public void save() {
8687 try {
8788 fos = context .openFileOutput (fileID , Context .MODE_PRIVATE );
8889 } catch (FileNotFoundException e ) {
89- // Log.d ("PersistenceManager", "FileNotFoundException" );
90+ Log .w ("PersistenceManager" , Log . getStackTraceString ( e ) );
9091 }
9192
9293 ObjectOutputStream o ;
@@ -102,7 +103,7 @@ public void save() {
102103 }
103104
104105 } catch (IOException e ) {
105- // Log.d ("PersistenceManager", "IOException "+e );
106+ Log .w ("PersistenceManager" , Log . getStackTraceString ( e ) );
106107 }
107108
108109 SharedPreferences .Editor editor = context .getSharedPreferences (preferenceID , 0 ).edit ();
0 commit comments