Ken Gordon
Newbie
I'm following( or trying to) a tutorial showing how to work with a listview.
1. Created a new class with getters/setters and contructor with the elements in the database table.
When it came to the view function in the database helper class, the example initialized a list(arraylist) and a new instance of the class created in number 1. For whatever reason, the compiler doesn't like my instance name, it seems to want the elements within the class.
Just for fun, here is the Car class
I used the generate for this section. What am I missing? Thanks!
1. Created a new class with getters/setters and contructor with the elements in the database table.
When it came to the view function in the database helper class, the example initialized a list(arraylist) and a new instance of the class created in number 1. For whatever reason, the compiler doesn't like my instance name, it seems to want the elements within the class.
Java:
public List<Car> ViewCar() //Cursor was the return type
{
try
{
List<Car> carlist=new ArrayList<Car>();
SQLiteDatabase db=this.getWritableDatabase();
Cursor result=db.rawQuery("select * from "+CAR_TABLE, null);
if(result.moveToFirst())
{
do{
Car car=new Car(); (Car in Car() cannot be applied to: shows all the strings)
car.setMake(result.getString(0));
car.setModel((result.getString(1)));
car.setYear(result.getString(2));
car.setMileage(result.getString(3));
}
while (result.moveToNext());
}
db.close();
return carlist;
}
catch(Exception e)
{
return null;
}
}
Just for fun, here is the Car class
Java:
public class Car
{
private String Make, Model, Year, Mileage;
public Car(String make, String model, String year, String mileage)
{
Make = make;
Model = model;
Year = year;
Mileage = mileage;
}
public String getMake()
{
return Make;
}
public void setMake(String make)
{
Make = make;
}
public String getModel()
{
return Model;
}
public void setModel(String model)
{
Model = model;
}
public String getYear()
{
return Year;
}
public void setYear(String year)
{
Year = year;
}
public String getMileage()
{
return Mileage;
}
public void setMileage(String mileage)
{
Mileage = mileage;
}
}
I used the generate for this section. What am I missing? Thanks!