• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Problems with Databae

Ok, getting better. LogCat is showing an error that it can't find "_id" in the table (but I know it's there as I can see the schema in sqlite3

Code:
    public Cursor getRow(long rowId) throws SQLException {
     
      Cursor myCursor =
          myDataBase.query(true, "zip", new String[]    {
           "_id", "zip", "city"},
          "_id" + "=" + rowId, null, null, null, null, null);
      
      if (myCursor != null) {
          myCursor.moveToFirst();
      }
      return myCursor;
     
    }
    }
 
Upvote 0
Thanks, but it's gone beyond that now and I'm about sick :) LOL Was up till 4 in the morning working on this...now my damn database won't open.
12-01 12:00:55.286: ERROR/Database(367): sqlite3_open_v2("C:/Users/david/workspace/ZipCode/assets/zipcode.db", &handle, 1, NULL) failed

The db file is there in assets...I can see it. I can open it with SQL Lite Browser. I'm actually sick to my stomach at this point...

Wiped out database, uninstalled application, rebooted laptop, create NEW database with NEW name and still won't open....ugh

Also, this is a database created on my PC, NOT through the app. I might just try to create it in the app, but I need a pre-loaded database for the app...I really don't want to muck around loading it in the app...
 
Upvote 0
OMG...NEVER MIND....freakn' braces vs. parenthesis...man, I need better glasses!!!!!

Ok, getting closer...but I"m really stuck on this one.

Code:
public class myProgram extends Activity {

Button searchButton;

//other stuff
}
public void onCreate(Bundle savedInstanceState) {
 
        /** Setup Search Button */
       searchButton = (Button) findViewById(R.id.Search);
       setSearchbutton();
 // other stuff
}
    private void setSearchbutton() {
        
        searchButton.setOnClickListener {  // ERROR, Multiple Markers
        new View.OnClickListener()
        {
            @Override public void onClick(View v) {returnRow();}
        }  // ERROR, insert ';' 
      };
    }
No errors in "returnRow()"; it's just my database call
 
Upvote 0
setOnClickListener is a method so you have to user () instead of {}

like this:
Code:
public class myProgram extends Activity {

Button searchButton;

//other stuff
}
public void onCreate(Bundle savedInstanceState) {
 
        /** Setup Search Button */
       searchButton = (Button) findViewById(R.id.Search);
       setSearchbutton();
 // other stuff
}
    private void setSearchbutton() {
        
           searchButton.setOnClickListener( 
           new View.OnClickListener() {
              @Override 
              public void onClick(View v) {
                  returnRow();
              }
           }
        );
    }

This is fairly standard java code. Maybe you should read some more tutorials about java.
You should be able to figure out these errors by yourself.
 
Upvote 0
Maybe you shouldn't be so condescending. Nobody's perfect...and reading a tutorial is hardly going to teach me that.

If I recall when searching for a decent developer forum and found this one, there is a sticky about users and their responses; perhaps YOU need to read it :) Basically boils down to "if you don't have anything good or helpful to say, then just don't say anything".

Like I said, I caught the mistake and I need new glasses...my eyesight isn't that good and telling those apart is sometimes hard for me.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones