Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2
This is the forum to discuss the Wrox book Professional Android Application Development by Reto Meier; ISBN: 9780470344712
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 18th, 2009, 09:02 AM
Registered User
Join Date: Apr 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 6: Creating Table-example not working

So I followed the examples in chapter 6 for quickly creating a small database. But when I run this code the exception is thrown. How come? Im using SDK1.1

package simpleTest.database;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.Toast;

public class DBtest extends Activity {
    private static final String DATABASE_NAME = "myDatabase.db";
    private static final String DATABASE_TABLE = "mainTable";
    private static final String DATABASE_CREATE = "create table " + DATABASE_TABLE + " ( _id integer primary key autoincrement," +
    "column_one text not null);";
    SQLiteDatabase myDatabase;
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {

        myDatabase = openOrCreateDatabase(DATABASE_NAME, Context.MODE_PRIVATE, null);
        try {
            } catch (SQLException ex){
                Toast.makeText(getBaseContext(), "error...", 
Reply With Quote
  #2 (permalink)  
Old April 21st, 2009, 12:07 PM
Authorized User
Join Date: Mar 2009
Posts: 21
Thanks: 0
Thanked 3 Times in 3 Posts

Check for a Database error in the Log window, if you're using Eclipse. That will probably give you a good hint.
Reply With Quote
The Following User Says Thank You to sierawsk For This Useful Post:
sandstrp (April 27th, 2009)
  #3 (permalink)  
Old April 27th, 2009, 06:45 PM
Registered User
Join Date: Apr 2009
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts

why thank you, that helped. The table already existed, so the exception was thrown! ^__^
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
creating table ph0neman Classic ASP Basics 3 January 22nd, 2008 05:06 PM
creating a junction table sarah lee SQL Server 2000 1 January 10th, 2007 05:18 PM
Creating table with existing table without value kumar_kumar Oracle 1 January 4th, 2005 07:12 AM
Creating a medal table awood2000 XSLT 12 November 15th, 2004 07:26 AM
padding not working in table tag peter_vansteen@hotmail.co HTML Code Clinic 1 September 17th, 2003 08:41 PM

All times are GMT -4. The time now is 10:15 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.