I am using SQLite Database in Android. I have used rawQuery
in SQLite database. My Database method for that is as follows:
public Cursor selectedDate(String from_dt ,String to_dt)
{
try
{
String str_k="select RowId,Bill_Date from SalesMaster Where Bill_Date between '"+
from_dt+ "'and'"+to_dt+ "'";
System.out.println(str_k);
Cursor c1 = sqldb.rawQuery(
"select RowId from SalesMaster Where Bill_Date between '"+
from_dt+ "'and'"+to_dt+ "'", null);
return c1;
}
catch(Exception e)
{
System.out.println("inside database file "+ e);
return null;
}
}
and my .java file is
public void ReportSell(String from_dt,String to_dt)
{
System.out.println("report selling method has been called");
String RowId="";
item db1 = new item(getBaseContext());
db1.openDb();
try
{
final Cursor cursor = db1.selectedDate(from_dt, to_dt);
if(cursor.moveToFirst())
{
do
{
RowId= cursor.getString(cursor.getColumnIndex("RowId")).toString();
System.out.println("inside java Row Id file "+ RowId);
salesid.add(RowId);
ArrayAdapter <String> adapter = new ArrayAdapter <String>(this,
android.R.layout.simple_list_item_1,
salesid);
} while(cursor.moveToNext());
}
else
{
Toast.makeText(getApplicationContext(), "No data found",
Toast.LENGTH_LONG).show();
}
} catch(Exception e)
{
System.out.println("inside java file "+ e);
}
db1.closeDb();
}
The main problem is that it will return RowId
from salesMaster
table as per from-date and to-date, but actual problem is it will return values but not include last to-date.
For example, if I want to RowId
from 25/02/2015 to 28/02/2015
so it will give RowId
from 25/02/2015 to 27/02/2015 but not included 28/02/2015.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…