Index: trunk/autoquest-androidmonitor/src/de/ugoe/cs/autoquest/androidmonitor/AndroidmonitorLogFile.java
===================================================================
--- trunk/autoquest-androidmonitor/src/de/ugoe/cs/autoquest/androidmonitor/AndroidmonitorLogFile.java	(revision 1725)
+++ trunk/autoquest-androidmonitor/src/de/ugoe/cs/autoquest/androidmonitor/AndroidmonitorLogFile.java	(revision 1726)
@@ -2,44 +2,51 @@
 
 import java.io.File;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
+import java.io.FileOutputStream;
 import java.io.StringWriter;
 
 import org.xmlpull.v1.XmlSerializer;
 
-import android.app.Activity;
-import android.content.Context;
 import android.util.Log;
 import android.util.Xml;
 
-public class AndroidmonitorLogFile extends Activity {
-	// extends activity to use the file handling methods of an activity
+public class AndroidmonitorLogFile {
+
 	private String name;
 
+	public AndroidmonitorLogFile(String appName, File dir) {
+		this.name = "android_" + appName + "_LogFile.xml";
 
-	public AndroidmonitorLogFile(String appName, File dir) {		
-		this.name = appName + "LogFile.xml";
-		
 		try {
+			// prove if file exists
 			File file = new File(dir, this.name);
-			if (!file.exists()) {
-				Log.d("file", this.name + " - is not available");
-				
-				//create file
+			/*
+			 * if file does not exists write device and app information to a new
+			 * file. Otherwise use existing file and add activity information to
+			 * file.
+			 */
+			if (true) { //!file.exists() 
+				/*
+				 * create log file. Using method openFileOutput() does not work
+				 * for this project due to the reason that this method would try
+				 * to create the file in the directory of the non-existing
+				 * directory de.ugoe.cs.androidmonitor. This directory does not
+				 * exist due to the reason that this project is a library and
+				 * the file has to be stored in the directory of the running
+				 * application. Furthermore it would not be possible to write in
+				 * another app directory as the own one.
+				 */
+				String string = getDeviceInformation() + getAppInformation();
 				try {
-					OutputStreamWriter outputStreamWriter = new OutputStreamWriter(
-							openFileOutput(this.name, Context.MODE_PRIVATE));
-					outputStreamWriter.write(getDeviceInformation() + getAppInformation());
-					outputStreamWriter.close();
-				} catch (IOException e) {
-					e.printStackTrace();
-					Log.e("outputStreamWriter", e.getMessage());
+					FileOutputStream outputStream = new FileOutputStream(file);
+					outputStream.write(string.getBytes());
+					outputStream.close();
+				} catch (Exception e) {
+					Log.e("file", "outputstream: " + e.getMessage());
 				}
-				
 
 			}
 		} catch (Exception e) {
 			e.printStackTrace();
-			Log.e("file", e.getMessage());
+			Log.e("file", "file: " + e.getMessage());
 		}
 
@@ -59,55 +66,55 @@
 		return "";
 	}
-	
-	private String getDeviceInformation(){
-		String deviceInformation = null;
+
+	private String getDeviceInformation() {
+		String deviceInformation = "";
+		XmlSerializer serializer = Xml.newSerializer(); 
+		StringWriter writer = new StringWriter();
 		try {
-			XmlSerializer xmlSerializer = Xml.newSerializer();
-			StringWriter stringWriter = new StringWriter(); 
+			serializer.setOutput(writer);
+			serializer.startDocument("UTF-8", true);
+			serializer.startTag("", "device");
+			serializer.startTag("", "param");
+			serializer.attribute("", "value", ""
+					+ android.os.Build.VERSION.SDK_INT);
+			serializer.attribute("", "name", "sdk_version");
+			serializer.endTag("", "param");
+
+			serializer.startTag("", "param");
+			serializer.attribute("", "value", android.os.Build.DEVICE);
+			serializer.attribute("", "name", "device");
+			serializer.endTag("", "param");
+
+			serializer.startTag("", "param");
+			serializer.attribute("", "value", android.os.Build.MANUFACTURER);
+			serializer.attribute("", "name", "manufacturer");
+			serializer.endTag("", "param");
+
+			serializer.startTag("", "param");
+			serializer.attribute("", "value", android.os.Build.MODEL);
+			serializer.attribute("", "name", "model");
+			serializer.endTag("", "param");
+
+			// tbd get resolution ...
+
+			serializer.endTag("", "device");
+			serializer.endDocument();
 			
-			xmlSerializer.setOutput(stringWriter);
-			xmlSerializer.startDocument("UTF-8", true);
-			xmlSerializer.startTag("", "device");
-			xmlSerializer.startTag("", "param");
-			xmlSerializer.attribute("", "value", "" + android.os.Build.VERSION.SDK_INT);
-			xmlSerializer.attribute("", "name", "sdk_version");
-			xmlSerializer.endTag("", "param");
-			
-			xmlSerializer.startTag("", "param");
-			xmlSerializer.attribute("", "value", android.os.Build.DEVICE);
-			xmlSerializer.attribute("", "name", "device");
-			xmlSerializer.endTag("", "param");
-			
-			xmlSerializer.startTag("", "param");
-			xmlSerializer.attribute("", "value", android.os.Build.MANUFACTURER);
-			xmlSerializer.attribute("", "name", "manufacturer");
-			xmlSerializer.endTag("", "param");
-			
-			xmlSerializer.startTag("", "param");
-			xmlSerializer.attribute("", "value", android.os.Build.MODEL);
-			xmlSerializer.attribute("", "name", "model");
-			xmlSerializer.endTag("", "param");
-			
-			//tbd get resolution ...
-			
-			
-			xmlSerializer.endTag("", "device");
-			deviceInformation = stringWriter.toString();
-			
+			deviceInformation = writer.toString();
+
 		} catch (Exception e) {
-			e.printStackTrace();
-			Log.e("xmlSerializer", e.getMessage());
+			Log.e("xml", e.getMessage()); 
 		}
-		
+
 		return deviceInformation;
 	}
 
-	public void addComponent(){
-		//add component to file
+	public void addComponent() {
+		// add component to file
 	}
-	
-	public void addEvent(){
-		//add event to file
+
+	public void addEvent() {
+		// add event to file
 	}
-	
+
 }
