Hi,
I'm not sure what I'm doing wrong here:
I have an Override on onPause to save settings to a file and an
Override on onResume, and onCreate to load them back up from the file.
The onPause method looks like this:
@Override
public void onPause()
{
super.onPause();
// save configuration settings
if (cfg != null)
{
byte[] settingsBuffer =
cfg.toSerializedBytes(getBaseContext());
Log.v(LogName.onPause, LogName.onPause + ": settings
Buffer : " +
settingsBuffer.length);
try
{
FileOutputStream fos =
openFileOutput(settingsFile,
getBaseContext().MODE_WORLD_READABLE);
fos.write(settingsBuffer);
fos.getFD().sync();
fos.close();
}
catch (FileNotFoundException e)
{
Log.e(LogName.onPause, LogName.onPause + ":
File not found. " +
e.getMessage());
}
catch (IOException e)
{
Log.e(LogName.onPause, LogName.onPause + ": IO
Error. " + e.getMessage());
}
}
}
The load method looks like this:
public void loadSettings()
{
File inputFile = new File(settingsFile);
if (inputFile.exists())
{
byte[] settingsBuffer = new byte[(int)
(inputFile.length())];
try
{
FileInputStream fis =
openFileInput(settingsFile);
fis.read(settingsBuffer);
cfg =
RXConfigurationSettings.fromSerializedBytes(settingsBuffer);
if (cfg != null)
{
cfg.populateTable((TableLayout)
findViewById(R.id.tableLayoutConfigurationSettingsTable),
getBaseContext());
}
fis.close();
}
catch (FileNotFoundException e)
{
Log.e(LogName.onResume, LogName.onResume + ":
File not found. " +
e.getMessage());
}
catch (IOException e)
{
Log.e(LogName.onResume, LogName.onResume + ":
IO Error. " + e.getMessage());
}
}
else
{
Log.e(LogName.className, "Input FILE not found.");
}
}
The loadSettings is called from onCreate and onResume but I seem to
always hit the else condition and logcat always shows "Input FILE not
found.".
Can anyone provide insight into this problem?
Thanks
-jm
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en