Using java Syntax Highlighting
- public class DataBaseWork extends ListActivity {
- public static final String MY_DATABASE_NAME = "ActivityLog";
- public static final String MY_DATABASE_TABLE = "logtable";
- public static SQLiteDatabase myDB = null;
- /** Called when the activity is first created. */
- DataBaseWork(){
- try{
- this.createDatabase(MY_DATABASE_NAME, 1, MODE_PRIVATE, null);
- myDB = this.openDatabase(MY_DATABASE_NAME, null);
- myDB.execSQL("CREATE TABLE IF NOT EXISTS "
- + MY_DATABASE_TABLE
- + " (Date VARCHAR, serverIP VARCHAR ;");
- } catch (FileNotFoundException e) {
- }
- }
- public void addentry(String servIP)
- {
- Date d = new Date();
- String cdate = new String(d.toString());
- myDB.execSQL("INSERT INTO "
- + MY_DATABASE_TABLE
- + " (Date, serverIP)"
- + " VALUES (cdate, servIP);");
- }
- }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
I tried to create an object of the above class in java file main as follows :
DataBaseWork dbw;
dbw = new DataBaseWork();
I'm getting the following error :
unable to start activity ComponentInfo{tel.net.client/tel.net.client.Main}:
java.lang.RuntimeException : not supported in system context.
I am sure that this error is because of the database work because after removing that piece of code the program works fine.
PS: I'm using the very first android SDK (m3r20a) and finding it convenient to use the same rather than upgrading to the latest version.



