Created
September 21, 2017 02:19
-
-
Save PauloCeami/ba6118b16bd9adaad604660355907319 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<Produto_SqliteBean> getAll(String field, String query) { | |
List<Produto_SqliteBean> listadeprodutos = new ArrayList<>(); | |
SQLiteDatabase db = new Db(ctx).getReadableDatabase(); | |
try { | |
cursor = db.rawQuery("select * from PRODUTOS where " + field + " like '%" + query + "%'", null); | |
while (cursor.moveToNext()) { | |
Produto_SqliteBean prd = new Produto_SqliteBean(); | |
prd.setPrd_codigo(cursor.getInt(cursor.getColumnIndex(prd.CODIGO_PRODUTO))); | |
prd.setPrd_EAN(cursor.getString(cursor.getColumnIndex(prd.CODIGO_BARRAS_EAN_13))); | |
prd.setPrd_descricao(cursor.getString(cursor.getColumnIndex(prd.DESCRICAO_PRODUTO))); | |
prd.setPrd_descr_red(cursor.getString(cursor.getColumnIndex(prd.DESCRICAO_REDUZIDA))); | |
prd.setPrd_unmed(cursor.getString(cursor.getColumnIndex(prd.UNIDADE_MEDIDA))); | |
prd.setPrd_custo(new BigDecimal(cursor.getDouble(cursor.getColumnIndex(prd.PRECO_DE_CUSTO)))); | |
prd.setPrd_preco(new BigDecimal(cursor.getDouble(cursor.getColumnIndex(prd.PRECO_DE_VENDA)))); | |
prd.setPrd_quant(new BigDecimal(cursor.getDouble(cursor.getColumnIndex(prd.QUANTIDADE_ESTOQUE)))); | |
prd.setPrd_categoria(cursor.getString(cursor.getColumnIndex(prd.CATEGORIA))); | |
listadeprodutos.add(prd); | |
} | |
} catch (SQLiteException e) { | |
Log.d("getAll", e.getMessage()); | |
} finally { | |
db.close(); | |
} | |
return listadeprodutos; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment