Segue a classe Elidio.
-- De repente seria viável executar em um try/catch?
public class DatabaseManager extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "crudapplication_db"; private static final int DATABASE_VERSION = 1;
private SQLiteDatabase database;
public DatabaseManager(Context context) { super(context, DatabaseManager.DATABASE_NAME, null, DatabaseManager.DATABASE_VERSION); }
@Override public void onCreate(SQLiteDatabase db) { db.execSQL(Usuario.CREATE_TABLE_SCRIPT); }
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
public Cursor select(boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) { this.openDatabase(); Cursor cursor = this.database.query(distinct, table, columns, selection, selectionArgs, groupBy, having, orderBy, limit); return cursor; }
public long insert(String table, String nullCollumnHack, ContentValues contentValues) { this.openDatabase(); long id = this.database.insert(table, nullCollumnHack, contentValues); this.closeDatabase(); return id; }
public int update(String table, ContentValues values, String whereClause, String[] whereArgs) { this.openDatabase(); int rowsAffected = this.database.update(table, values, whereClause, whereArgs); this.closeDatabase(); return rowsAffected; }
public int delete(String table, String whereClause, String[] whereArgs) { this.openDatabase(); int rowsAffected = this.database.delete(table, whereClause, whereArgs); this.closeDatabase(); return rowsAffected; }
private void openDatabase() { if (this.database == null) { this.database = this.getWritableDatabase(); } }
public void closeDatabase() { if (this.database != null) { this.database.close(); this.database = null; } }}You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.






0 comentários:
Postar um comentário