You probably want to move the CREATE TABLE code into the onCreate()
method.  You also want to use a static final int internal to your
SQLiteOpenHelper to help manage versions.  (The database version
number shouldn't be dictated by the person constructing the helper.)

When calling the super() constructor, SQLiteOpenHelper checks its
current version against the one you supply, and calls onUpgrade() and
onCreate() as needed.

j

On Wed, Apr 15, 2009 at 10:25 PM, Neo <[email protected]> wrote:
>
> public class DatabaseHelper extends SQLiteOpenHelper{
>
> public DatabaseHelper(Context context, String name, CursorFactory
> factory,
> int version) {
> super(context, name, null, version);
> // TODO Auto-generated constructor stub
> init();
> }
>
> @Override public void onCreate(SQLiteDatabase db) {}
> @Override
> public void onUpgrade(SQLiteDatabase db, int oldVersion, int
> newVersion) {}
>
>
> private void init()
> {
> SQLiteDatabase Rdb = getReadableDatabase();
> String Rsql = "select count(*) from sqlite_master where name='good'
> and type='U'";
>
> try { Rdb.execSQL(Rsql)
> catch (SQLException Re) {
> Log.e("ERROR", Re.toString());
> SQLiteDatabase Wdb = getWritableDatabase();
> String Wsql = "create table good(" + "stud_no text not null, "
> + "stud_name text );";
> try { Wdb.execSQL(Wsql); }
> catch (SQLException We) {
> Log.e("ERROR", We.toString());
> }
> close();
> }
> }
> }
>
> if the table created, restart again the check str is fail
>
> the Rsql right or not ??
>
> please help me !
> thanks
> >
>



-- 
Jeff Sharkey
[email protected]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to