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 9291317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:37:02+00:00 2026-06-18T20:37:02+00:00

I am using editText input type is date and i want that user will

  • 0

I am using editText input type is date and i want that user will enter date in date format and store it in a datetime field of a table in sqlite. Is this possible? Because the editText date format is dd/mm/yyyy and in sqlite it is yyyy/mm/dd.

I have designed one form on which there is a edit text by which user will enter a date and i want to store this date in sqlite whose field’s type is datetime.How to do it? I am new to android so if anybody know the solution please provide me the answer.

  • 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-18T20:37:03+00:00Added an answer on June 18, 2026 at 8:37 pm

    I have solved my issue:

    1. I have taken Datatype of date is datetime in sqlite3 .
    2. I have used textview,datepicker and a button in date_picker_demo.xml saved in layout.

    3. DatePicker.java

      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
              db = new DatabaseHelper(this);
              date_textview = (TextView) findViewById(R.id.tv_date);
              picker_date = (DatePicker) findViewById(R.id.datepicker1);
              button_create = (Button) findViewById(R.id.button_create);
      }
      
      @Override 
      public void onClick(View arg0) {
          date = new Date(picker_date.getYear()-1900, picker_date.getMonth(), picker_date.getDayOfMonth()); 
              sdf = new SimpleDateFormat("yyyy-MM-dd");
      
             //sdf.format()->converting date to string
      String sdate = sdf.format(date); 
      
            //inserting date into database
               try {
          db.createDataBase();
      } catch (IOException e) {
          e.printStackTrace();
      }
      db.openDataBase();
      Cursor cur = db.select();
      
      for(cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()){
          if(cur.isLast()){
              s_id = Integer.parseInt(cur.getString(0));
              s_id = s_id + 1;
          }
      }
               db.insertDate(s_id,sdate);
         }
      
    4. DatabaseHelper.java

       public Cursor select(){
       String qry = "Select subscription_id from Subscription_Master";
       cur = sqdb.rawQuery(qry,null); 
      return cur;
       }
      
       public void insertDate(int s_id,String s_date){
      
      String query = "insert into Subscription_TAB(subscription_id,start_date) values("+s_id+",date('"+s_date+"'))";
       sqdb.execSQL(query);
       Log.d("value","inserted");
       }
      

    Date is inserted in database successfully.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that when using a EditText we can change the input type using
i am using an edittext for the user input in which user entered his
Using a populated Table Type as the source for a TSQL-Merge. I want to
What is the best way to store previously entered user input from an EditText
I m using one EditText field and one spinner. I have to pass teh
I need a EditText that fills in height my window. I'm using this: <ScrollView
I want to display custom search in actionbar (I'm using ActionBarSherlock for that). I
I have an EditText using android:inputType=textPostalAddress as the keyboard type. I would like it
If I disable an EditText widget using editText.setEnabled(false); I can still type into it
I'm trying to create a android layout like: [####EditText###][Button] [####listview#####] For that i'm using

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.