Skip to content

Commit

Permalink
stopped saving throwing exception if the file doesn't exist - KB
Browse files Browse the repository at this point in the history
  • Loading branch information
thk123 committed Jul 31, 2012
1 parent e2649fd commit 95a3255
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/App/src/dimappers/android/pub/AppUserArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void readXml(Element element) {
List<Element> friendsElements = element.getChild(friendsTag).getChildren(AppUser.class.getSimpleName());

internalArray = new AppUser[friendsElements.size()];
for(int i = 0; i<=friendsElements.size(); i++)
for(int i = 0; i<friendsElements.size(); i++)
{
AppUser friend = new AppUser(friendsElements.get(i));
internalArray[i] = friend;
Expand Down
1 change: 0 additions & 1 deletion Source/App/src/dimappers/android/pub/CurrentEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ public void setData(IPubService serviceInterface) {

@Override
public View getView(int position, View convertView, ViewGroup parent) {
Log.d(Constants.MsgInfo, "current postion:" + position);
if(getItem(position) instanceof ListHeader)
{
View layout = (((LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE)).inflate(R.layout.header, null));
Expand Down
19 changes: 19 additions & 0 deletions Source/App/src/dimappers/android/pub/StoredData.java
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,25 @@ public static String readFile(Context context, String fileName)
{
String storedDataString = "";
FileInputStream file = null;

//check file exists
String[] files = context.fileList();
boolean found = false;
for(int i = 0; i<files.length; i++)
{
if(files[i].equals(fileName))
{
found = true;
break;
}
}
if(!found)
//if the file has not been found (prevents an exception being thrown by openFileInput(..)
{
Log.d(Constants.MsgWarning, "The file " + fileName + " has not been found.");
return "";
}

try
{
file = context.openFileInput (fileName);
Expand Down

0 comments on commit 95a3255

Please sign in to comment.