Hi,

 

Am I missing something here or are you setting your database pointer to "null" 
and yet use it later on to crate/open your database ?

 

Emre
 
> Date: Thu, 20 Aug 2009 16:08:35 -0700
> Subject: [android-beginners] database openOrCreateDatabase
> From: gand...@gmail.com
> To: android-beginners@googlegroups.com
> 
> 
> Hi Guys,
> 
> I am creating a new database, with a table and inserting some fields
> in it
> But I get the following error in opening or creating database.
> 
> What am I missing ?
> 
> Thanks a lot
> 
> 
> >>> ERROR/Database(167): sqlite3_open_v2("data2", &handle, 6, NULL) failed
> 
> 
> 
> code follows......
> 
> public class DataBaseWork extends Activity {
> /** Called when the activity is first created. */
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
> 
> ArrayList<String> results = new ArrayList<String>();
> SQLiteDatabase myDB = null;
> String MY_DATABASE_TABLE = "t_Users";
> try {
> /* Create the Database (no Errors if it already exists) */
> myDB.openOrCreateDatabase("data2", null);
> myDB.execSQL("CREATE TABLE IF NOT EXISTS "
> + MY_DATABASE_TABLE
> + " (LastName VARCHAR, FirstName VARCHAR,"
> + " Country VARCHAR, Age INT(3));");
> myDB.execSQL("INSERT INTO "
> + MY_DATABASE_TABLE
> + " (LastName, FirstName, Country, Age)"
> + " VALUES ('Ggggggg', 'Nnnnnn', 'Geeeeeeee',
> 20);");
> 
> } catch (SQLException e){
> 
> }
> 
> 
> if (myDB != null)
> myDB.close();
> 
> 
> }
> }
> > 

_________________________________________________________________
Stay on top of things, check email from other accounts!
http://go.microsoft.com/?linkid=9671355
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to