on 2013 Feb 11 3:35 AM
I'd like to connect to an existing DB or to create one and create tables if they don't exist. The problem is that the app just breaks, the VS debugger stops at line IConnection cn = DatabaseManager.Connect(config); The program does not enter into the catch clause.
public static IConnection GetConnection(Context context) { IConfigPersistent config = DatabaseManager.CreateConfigurationFileAndroid("MobileDb1.udb", context); try// Connect, or if the database does not exist, create it and connect { IConnection cn = DatabaseManager.Connect(config); return cn; } catch (ULjException e) { IConnection cn = DatabaseManager.CreateDatabase(config); CreateDatabaseTables(cn); InsertDemoValues(cn); return cn; } }
This works with UltraLiteJ APIs:
ConfigFileAndroid config = null; Connection conn; try { config = DatabaseManager.createConfigurationFileAndroid("test.udb", this); Log.d("test", "connecting to database"); conn = DatabaseManager.connect(config); } catch (ULjException e) { if (e.getErrorCode() == ULjException.SQLE_ULTRALITE_DATABASE_NOT_FOUND) { try { Log.d("test", "creating database"); conn = DatabaseManager.createDatabase(config); // create tables... } catch (ULjException ee) { Log.e("test", ee.toString()); } } }
I am not familiar enough with Mono for Android to definitively address your issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
8 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.