Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8394799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:08:49+00:00 2026-06-09T20:08:49+00:00

I am new sqlite. I have one table that having 3 columns 1. Id

  • 0

I am new sqlite. I have one table that having 3 columns

1. Id
2. FoodName
3. Date and time

(ex: '1' 'Chicken' '2012-08-10 13:54') 

I read somewhere Android sqlite doesn’t provide date data type.

So I used the text data type for storing the date in local db. it’s working fine.

Now I want to write a query for retrieving the record between two dates. I tried but I am not getting it.

==>> code

public class FoodDB {

//Database Related Constants
public static final String KEY_ROWID = "id";
public static final String KEY_NAME = "fooditem";
public static final String KEY_TIMESTAMP = "timestamp";   

private static final String DATABASE_NAME = "AJFoodDB";
private static final String DATABASE_TABLE = "AJ_Food";
private static final int DATABASE_VERSION = 1;

Cursor c;
long id;

private static final String DATABASE_CREATE =
    "create table "+DATABASE_TABLE+" (id integer primary key autoincrement, "               
     + KEY_NAME+" text not null,"
     + KEY_TIMESTAMP+" text not null);";

private  final Context context;
private DatabaseHelper DBHelper;
private SQLiteDatabase sqlitedatabase;

public FoodDB(Context ctext){
    context = ctext;        
}

private static class DatabaseHelper extends SQLiteOpenHelper
{
    DatabaseHelper(Context context)
    {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    public void onCreate(SQLiteDatabase db)
    {
        db.execSQL(DATABASE_CREATE);                     
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
    {
        db.execSQL("DROP TABLE IF EXISTS titles");
        onCreate(db);
    }
}

//Insert Row
public void insertSSFiltersDetails(String keyname, String timestamp){
    try 
    {
        DBHelper = new DatabaseHelper(context);
        sqlitedatabase = DBHelper.getWritableDatabase();
        insertRow(keyname, timestamp);    
        sqlitedatabase.close();

    } catch (Exception e) {
        System.out.println("Error from inserting data->"+e.toString());
    }
}

public long insertRow(String keyname, String timestamp){
    ContentValues initialValues = new ContentValues();
    initialValues.put(KEY_NAME, keyname);
    initialValues.put(KEY_TIMESTAMP, timestamp);       
    return sqlitedatabase.insert(DATABASE_TABLE, null, initialValues);
}

//Close Data Base
public void closeDBHelper(){
    if(DBHelper != null){
        DBHelper.close();
    }       
    if (c != null) {
        c.close();
        c = null;
    }
}       }

Query and Table
select * from AJ_Food;

1|rice   |8/12/2011 16:11
2|Rice   |8/13/2012 11:42
3|chicken|8/13/2012 11:42
4|Prawans|8/13/2012 11:43
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:08:51+00:00Added an answer on June 9, 2026 at 8:08 pm

    Even if you have taken text for date in sqlite. You can write the following query to select data between two dates.

    select column from Table where columnDate between '2012-07-01' and '2012-07-07'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table in sqlite that contain only one record and I want to
Fairly new to database schema (plan to use SQLite). Having said that, I'm thinking
I have a sqlite table that was originally created with: PRIMARY KEY (`column`); I
I'm attempting to delete all rows in one table that do not have a
I have a sqlite database with only one table (around 50,000 rows) and I
I have a drill down tableview that is using sqlite. The first one is
I have started using SqLite recently, so I am relatively new to it. I
I'm new to android apps development and I have a basic sqlite question. What
I am new to using the SQLite database in iphone apps. I have created
I am a bit new to SQLite , and I am having a slight

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.