3

I am developing an Android application where I want to make a database. I have extended the SQLiteOpenHelper class but it's not working for me. Can anybody tell me how to make database through it or any other syntax or code? Please provide me some good tutorial or example to study the database creation and implementation in the application.

Here is my logcat file from an attempt to follow a vogella.de tutorial:

06-17 13:20:11.883: ERROR/AndroidRuntime(1474): FATAL EXCEPTION: main
06-17 13:20:11.883: ERROR/AndroidRuntime(1474): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{de.vogella.android.todos.database/de.vogella.android.todos.database.TodoDatabaseHelper}: java.lang.InstantiationException: de.vogella.android.todos.database.TodoDatabaseHelper
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1544)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at android.os.Looper.loop(Looper.java:123)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at android.app.ActivityThread.main(ActivityThread.java:3647)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at java.lang.reflect.Method.invokeNative(Native Method)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at java.lang.reflect.Method.invoke(Method.java:507)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at dalvik.system.NativeStart.main(Native Method)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474): Caused by: java.lang.InstantiationException: de.vogella.android.todos.database.TodoDatabaseHelper
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at java.lang.Class.newInstanceImpl(Native Method)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at java.lang.Class.newInstance(Class.java:1409)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1536)
06-17 13:20:11.883: ERROR/AndroidRuntime(1474):     ... 11 more
06-17 13:20:12.004: WARN/ActivityManager(68):   Force finishing activity de.vogella.android.todos.database/.TodoDatabaseHelper
Beryllium
  • 12,808
  • 10
  • 56
  • 86
Avi Kumar
  • 4,403
  • 8
  • 36
  • 67
  • @Adil can u check the ttutiral at http://www.vogella.de/articles/AndroidSQLite/article.html its same it has four classes so would be too many classes to display – Avi Kumar Jun 17 '11 at 09:21
  • did you just copied the code or you imported the project into eclipse...? – Adil Soomro Jun 17 '11 at 09:54
  • Would you look at this [thread](http://stackoverflow.com/questions/4688277/java-lang-runtimeexception-unable-to-instantiate-activity-componentinfo)... is your issue is same as in this thread...? if so than follow the thread and let us know...!! – Adil Soomro Jun 17 '11 at 10:27
  • one thing diffrenr Adil there exception is java.lang.ClassNotFoundException and my exception java.lang.RuntimeException: Unable to instantiate activity – Avi Kumar Jun 17 '11 at 10:49
  • @JaydeepKhamar Thank you for fixing the formatting, but please do not add things like “please help” or “thank you” to questions, and remove them if you see them. Like [signatures](http://stackoverflow.com/faq#signatures), these do not carry any information, they're just fluff. Please read [Should 'Hi', 'thanks' and taglines and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-and-taglines-and-salutations-be-removed-from-posts). – Gilles 'SO- stop being evil' Jun 18 '11 at 08:09

3 Answers3

2

Here is some tutorial for you.

http://www.vogella.de/articles/AndroidSQLite/article.html

http://sree.cc/google/android/creating-sqlite-database-tables-in-android

If you googling with "SQLite Tutorial for Android", there will be about 3,620,000 results in less than 1 second.

Hein
  • 2,675
  • 22
  • 32
  • @ Thanx for reply HERO i have tried the code of vogella.de but it crashes earlie it was showing null pointer exception whe was entering data but now it just crahes can you suggest somthing on basis of my logcat file – Avi Kumar Jun 17 '11 at 09:08
2

i Suggest the Android Notepad tutorial about making a content provider.

Sample

Tutorial

DArkO
  • 15,880
  • 12
  • 60
  • 88
2

Here is a nice tutorial on Android + Database usage that interests you.

http://www.anotherandroidblog.com/2010/08/04/android-database-tutorial/

A very detailed explanation here:

http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

Rakesh Sankar
  • 9,337
  • 4
  • 41
  • 66