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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:39:40+00:00 2026-06-09T16:39:40+00:00

here i take the latude and longtude from the user then i converted it

  • 0

here i take the latude and longtude from the user then i converted it into integer and here is the problem the log cat msg is :

unable to convert 30.01 into int ! then i enter the lat and lon into my table in the database:

  public class newMission extends Activity 
  implements OnClickListener{
SQLiteDatabase sql;
EditText e1,e2,e3,e4;
Button b;
MaptoDo obj;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    Intent in =getIntent();
    setContentView(R.layout.newmission);
    e1=(EditText) findViewById(R.id.edn1);
    e2=(EditText) findViewById(R.id.edn2);
    e3=(EditText) findViewById(R.id.edn3);
    e4=(EditText) findViewById(R.id.edn4);
    b=(Button) findViewById(R.id.btnew);
    b.setOnClickListener(this);
    obj=new MaptoDo();
    sql=openOrCreateDatabase("db",0, null);
    sql.execSQL("CREATE TABLE Mission" +
            "" +
            " (emp integer REFERENCES Employee2 (password)," +
            "oper_n text,cust_n text,lat double," +
            "long double,oper_id integer PRIMARY KEY AUTOINCREMENT)");
}
@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    String opN=e1.getText().toString();
    String cuN=e2.getText().toString();
    String lats=e3.getText().toString();
    String lons=e4.getText().toString();
     try {
  int lat=Integer.parseInt(lats);
  int lon=Integer.parseInt(lons);
  sql.execSQL("insert into Mission (oper_n,cust_n,lat,long)values('"+opN+"','"+cuN+"',"+lat+","+lon+");");
  Toast.makeText(this,"Data Inserted",2000).show();
  obj.addMission(lat, lon); 
    //add to ToDo list too 
}catch (NumberFormatException nfe) {
    Toast.makeText(this, "Please Enter Valid Data",2000).show();
}}

}

  • 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-09T16:39:42+00:00Added an answer on June 9, 2026 at 4:39 pm

    Try using the double datatype first.

    double dLat=Double.parseDouble(lats);
    double dLon=Double.parseDouble(lons);
    

    Then its a matter of getting the value before the decimal point:

    int lat = (int)Math.floor(dLat);
    int lon = (int)Math.floor(dLon);
    

    Or if you want – you can run a regular expression on the input first to make sure it has digits [dot] digits otherwise the extraction of the inputs to numeric will fail, but having said that, that would be dependent on how the layout for the EditText has it set up for certain input types – android:inputType within the XML layout.

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

Sidebar

Related Questions

The goal here is to take some list of coordinates, like [[1,2],[3,4],[7,1]] , then
So here's my schema (give or take): cmds.Add(@CREATE TABLE [Services] ([Id] INTEGER PRIMARY KEY,
The php code of barcode generator (which take from here http://www.barcodephp.com/en/userguide ) looks like
Please take a look here: alt text http://img16.imageshack.us/img16/2810/errrp.jpg Why i got that error when
Here's my (code golf) challenge: Take two arrays of bytes and determine if the
Take a look at this example here: http://denise.brixwork.com/showlisting/1/8297-Valley-Drive-Alpine-Meadows-Whistler-denise-brown-real-estate And the red tables under Specifications
Here is a very and straight forward question: How long will it take to
Here's what I mean by weird: Items usually take 2 presses to have their
take a look at the JsFiddle here: http://jsfiddle.net/ru2Fg/2/ Essentially, it starts with two textarea
Here is my ultimate goal... to take this xml file.. <?xml version=1.0?> <Songs> <Song>

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.