Выше приведен код, который позволит мне конвертировать между двумя разными единицами, однако, добавив selection, selectionArgs и projection в запрос, который вылетает при нажатии кнопки ввода.
DatabaseHelper dbhelper = new DatabaseHelper(getContext());
SQLiteDatabase database = dbhelper.getReadableDatabase();
String[] projection = {DatabaseContract.FeedEntry.COLUMN_NAME_Ratio};
// filter results WHERE column unit from and column unit to = input and result to string
String selection = DatabaseContract.FeedEntry.COLUMN_NAME_UNIT_FROM +
" = ?" + " AND " + DatabaseContract.FeedEntry.COLUMN_NAME_UNIT_CONVERTING_TO
+ " = ?";
String[] selectionArgs = {fromText.getText().toString(), toText.getText().toString()};
// the table to the query, the array of columns to return, the columns for the WHERE clause,
// the values for the WHERE clause, dont group the rows, dont filter by rows, not to be sorted
Cursor cursor = database.query(DatabaseContract.FeedEntry.TABLE_NAME, null, null,
null, null, null, null);
ArrayList<String> itemIds = new ArrayList<>();
while (cursor.moveToNext()){
String itemId = cursor.getString(cursor.getColumnIndexOrThrow
(DatabaseContract.FeedEntry.COLUMN_NAME_Ratio));
itemIds.add(itemId);
// to check the items present in the array list
Log.e("Array list",itemIds.toString());
}
cursor.close();
int toBeConverted = Integer.parseInt(input.getText().toString());
double findRatio = Double.parseDouble(itemIds.get(0));
double conversion = toBeConverted * findRatio;
result.setText(String.valueOf(conversion));
}