public void createTables(ConfigDatabaseOperations cdo) { try { cdo.getWritableDatabase().execSQL(createConfigTableQuery); Log.d(" String ", createConfigTableQuery); } catch (Exception e) { Log.d(" Error ", e.getMessage()); } finally { cdo.close(); } }
public int getHighestId(SQLiteDatabase sqlitedb) { Integer id = null; try { // final String MY_QUERY = "SELECT MAX(id) As id FROM " + // ConfigTableData.TimeConfigTableInfo.Config_Table; final String MY_QUERY = " SELECT * FROM " + ConfigTableData.TimeConfigTableInfo.Config_Table + " ORDER BY id DESC LIMIT 1"; Cursor mCursor = sqlitedb.rawQuery(MY_QUERY, null); if (mCursor.moveToFirst()) { id = mCursor.getInt(0); System.out.println(mCursor.getInt(0)); System.out.println(mCursor.getInt(1)); return (id); } else return (0); } catch (Exception e) { Log.d(" Error ", e.getMessage()); } finally { sqlitedb.close(); } if (id == null) return 0; else return id; }