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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:47:13+00:00 2026-05-25T18:47:13+00:00

as you can see from the code below im just trying to get the

  • 0

as you can see from the code below im just trying to get the coords pushed out to the logcat. however i never see the message or the coords. it shows me the sql string then finishes. so i believe the try is failing but even the catch statement doesnt return anything.

Button ButtonMap = (Button) findViewById(R.id.ButMap);
   ButtonMap.setOnClickListener(new View.OnClickListener() {

          public void onClick(View v) {
           try {
         /* Query for some results with Selection and Projection. */
            String sql = "SELECT _id,Longitude,Latitude FROM " + MY_DATABASE_TABLE + " WHERE _id = "+ID;
          Cursor c = db.rawQuery(sql,null);
           //db.query(MY_DATABASE_TABLE, new String[] {"_id", "Longitude", "Latitude"}, 
                      // "_id = " + "'%"+ID+"%'", null, null, null, null);
                  Log.e("SQL Select", sql);


         /* Get the indices of the Columns we will need */
         int longitude, latitude ;
            longitude = c.getColumnIndex("Longitude");
            latitude = c.getColumnIndex("Latitude");

         /* Check if our result was valid. */
          if (c.moveToFirst()) {
           int i = 0;
           /* Loop through all Results */ 
           do {
            i++;
            /* Retrieve the values of the Entry
             * the Cursor is pointing to. */
             double lat = c.getDouble(latitude);
              double lon = c.getDouble(longitude);            
                         Log.e("GPS", "location for this record is: lat="+lat+", lon="+lon);

           } while (c.moveToNext());
          }

        } catch (Throwable t) {
                  Log.e("GPS", t.toString());
       }
           finally {
         if (db != null)
          db.close();
        }

            Intent intent = new Intent();
                 setResult(RESULT_OK, intent);
                 finish();

       }

      });
 }
  • 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-05-25T18:47:14+00:00Added an answer on May 25, 2026 at 6:47 pm

    been to long to know exactly what fixed it but here is the answer code:

    import java.io.InputStream;
    import java.util.ArrayList;
    import java.util.List;
    
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    
    import org.w3c.dom.Document;
    import org.w3c.dom.NodeList;
    
    import android.content.ContentValues;
    import android.content.Context;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;
    import android.util.Log;
    
    
    public class SqlLiteFishLoggerDao extends SQLiteOpenHelper implements
            FishLoggerDao {
    
        private static final String DB_NAME = "fishingLog";
    
        private static final String TABLE_NAME = "LogEntries";
    
        private static final String DELETE_LOG_ENTRY_SQL = "DELETE FROM LogEntries WHERE _id = ?;";
    
        private static final String FIND_LOG_ENTRY_SQL = "SELECT * FROM LogEntries WHERE _id = ?";
    
        private static final String FIND_ALL_ENTRIES_SQL = "SELECT * FROM LogEntries";
    
        private static final String[] NO_ARGS = {};
    
        private Context context;
    
        private SQLiteDatabase DB;
    
        public SqlLiteFishLoggerDao(Context context) {
            super(context, DB_NAME, null, 1);
            this.context = context;
        }
    
        @Override
        public void deleteLogEntry(String id) {
            DB = getWritableDatabase();
            DB.execSQL(DELETE_LOG_ENTRY_SQL, new Object[] { id });
            DB.close();
        }
    
        @Override
        public LogEntry findEntry(String id) {
            DB = getReadableDatabase();
            Cursor cursor = DB.rawQuery(FIND_LOG_ENTRY_SQL,
                    new String[] { id });
            if (!cursor.moveToFirst()) {
                return null;
            }
            LogEntry entry = new LogEntry();
            entry.setId(cursor.getString(cursor.getColumnIndex("_id")));
            entry.setEntryDate(cursor.getString(cursor.getColumnIndex("CreateDate")));
            entry.setSpecies(cursor.getString(cursor.getColumnIndex("Species")));
            entry.setSizeOrWeight(cursor.getString(cursor.getColumnIndex("SizeOrWeight")));
            entry.setLatitude(cursor.getDouble(cursor.getColumnIndex("Latitude")));
            entry.setLongitude(cursor.getDouble(cursor.getColumnIndex("Longitude")));
            entry.setPictureUrl(cursor.getString(cursor.getColumnIndex("PictureURL")));
    
            cursor.close();
            DB.close();
            return entry;
    
        }
    
        @Override
        public void insertLogEntry(LogEntry entry) {
            DB = getWritableDatabase();
            ContentValues values = new ContentValues();
            values.put("Latitude", entry.getLatitude());
            values.put("Longitude", entry.getLongitude());
            values.put("PictureURL", entry.getPictureUrl());
            values.put("SizeOrWeight", entry.getSizeOrWeight());
            values.put("CreateDate", entry.getEntryDate());
            values.put("Species", entry.getSpecies());
            DB.insertOrThrow("LogEntries", null, values);
            DB.close();
        }
    
        @Override
        public void onCreate(SQLiteDatabase db) {
            String s;
            try {
                InputStream in = context.getResources().openRawResource(R.raw.sql);
                DocumentBuilder builder = DocumentBuilderFactory.newInstance()
                        .newDocumentBuilder();
                Document doc = builder.parse(in, null);
                NodeList statements = doc.getElementsByTagName("statement");
                for (int i = 0; i < statements.getLength(); i++) {
                    s = statements.item(i).getChildNodes().item(0).getNodeValue();
                    db.execSQL(s);
                }
                Log.e("DB", "DB Created Successfully");
            } catch (Throwable t) {
                Log.e("DB error: ",t.toString());
            }
        }
    
        @Override
        public List<LogEntry> findAllEntries() {
            DB = getReadableDatabase();
    
            List<LogEntry> entries = new ArrayList<LogEntry>();
    
            Cursor cursor = DB.rawQuery(FIND_ALL_ENTRIES_SQL,
                    NO_ARGS);
    
            if (cursor.moveToFirst()) {
                do {
                    LogEntry entry = new LogEntry();
                    entry.setId(cursor.getString(cursor.getColumnIndex("_id")));
                    entry.setEntryDate(cursor.getString(cursor.getColumnIndex("CreateDate")));
                    entry.setSpecies(cursor.getString(cursor.getColumnIndex("Species")));
                    entry.setSizeOrWeight(cursor.getString(cursor.getColumnIndex("SizeOrWeight")));
                    entry.setLatitude(cursor.getDouble(cursor.getColumnIndex("Latitude")));
                    entry.setLongitude(cursor.getDouble(cursor.getColumnIndex("Longitude")));
                    entry.setPictureUrl(cursor.getString(cursor.getColumnIndex("PictureURL")));
    
                    if (entry.getSpecies() == null) {
                        entry.setSpecies("Not Entered");
                    }
    
                    if (entry.getSizeOrWeight() == null) {
                        entry.setSizeOrWeight("Not entered");
                    }
    
                    entries.add(entry);
                } while (cursor.moveToNext());
            }
            cursor.close();
            DB.close();
            return entries;
        }
    
        @Override
        public void onUpgrade(SQLiteDatabase DB, int oldVersion, int newVersion) {
            DB = getWritableDatabase();
            DB.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
            onCreate(getWritableDatabase());
            DB.close();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some really funky code. As you can see from the code below
Despite trying lots of things (see below), I can't get rid of the Bytes
As you can see this is a question from a non web developer. I
How can I create a Popup balloon like you would see from Windows Messenger
How can I remove the animation from this jQuery modal window? You can see
While HTML Scraping is pretty well-documented from what I can see, and I understand
From a security perspective, I can see simply doing an 'eval' on incoming JSON
From http://developer.yahoo.com/yui/docs/YAHOO.util.DataSourceBase.html#method_sendRequest , you can see the oCallback is an object literal with the
I'm making this method retrieve records from the Data Base. As you can see
Say a table has several subclass types. How can I see all columns from

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.