Android sqlite database query with the columns needed taken from a String[]


soulcougher73
26/4/2016 6:52 am
HOME ยป Web Development

I have string array with columns I want to select:

String[] columns = {"col1", "col2", "col3"};

The columns might change in the future, but will always be a subset of available columns.

I cannot find a SQLiteDatabase API that lets me pass this array as columns. The only solution I have so far is to just string join the columns with , as separator and add it into my query string and perform a rawQuery.

Is there a better solution?

EDIT

The query is a JOIN query.


Related to : Android sqlite database query with the columns needed taken from a String[]
Android sqlite database query with the columns needed taken from a String[]
26/4/2016 6:52 am Web Development

I have string array with columns I want to select:

String[] columns = {"col1", "col2", "col3"};

The columns might change in the future, but will always be a subset of available columns.

I cannot find a SQLiteDatabase API that lets me pass this array as columns. The only solution I have so far is to just string join the columns with , as separator and add it into my query string and perform a rawQuery.

Is there a better solution?

EDIT

The query is a JOIN query.


Android development with sqlite: How to use string result from a database query without using a listview?
Web Development

I've been working on this for days, off and on. What I want to do is when a user clicks on a button, run a query against my sql lite database that returns 1 value (happens to be an integer, but string is fine), which I can then put into a text box. (Also When the user changes input values, and clicks the button, they get a different result.


I have gone through a ton of examples, but they all use a listview at the end to display a set of rows. Is there a way to take the results from my database adapter, which I thought was a string .
In my code from mydbadapter below, I would like to return a value from KEY_FEE column:


public String getda
Android “android.database.sqlite.SQLiteException: no such table” error when executing query on database
Web Development

I have a database which already contains a table "LocalLogin" and is properly set and can be queried without a problem, being set up the same way as my new table "PersonList". However when I try to execute a query on PersonList to select some values, I get the error


android.database.sqlite.SQLiteException: no such table: PersonList: , while compiling: SELECT ...

It gives me the idea that the table was never created, although I execute a create query in the onCreate method of my SQLiteOpenHelper class. Is having the same Database Name as LocalLogin the possible problem?


Here's the relevant code:


T

Android SQLite Database with Multiple Columns
Web Development

So I'm trying to make a database which has name, calorie, and protein columns. Here is the create statement:


public class SQLHelp extends SQLiteOpenHelper{
static final String DATABASE_NAME = "Food.db";
static final String TABLE_FOOD = "food";
static final String NAME_COLUMN = "FoodName";
static final String CALORIE_COLUMN = "Calorie";
static final String PROTEIN_COLUMN = "Protein";
static final String FAT_COLUMN = "Fat";
static final String COLUMN_ID = "id";
public SQLHelp(Context c){
super(c, DATABASE_NAME, null, 1);
}
public void onCrea


HD Wallpapers
3D
3D Abstract
City
Celebrities
Indian Celebrities
Cars
Travel
Girls
Animals Birds
Movies
Sports
Black White
Nature
Planes
Anime
Food Drink
Dreamy Fantasy
Architecture
Games
Space
Holidays
Flowers
Love
Artistic
Baby
Beach
Bikes Motorcycles
Macro
Computers
Vector
Funny
Army
Textures
Brands
Misc
Music
Other
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .