Green World

반응형

안드로이드 SQLite 소스







public class DBAccess extends SQLiteOpenHelper {


private static String DB_PATH ="";


private static String DB_NAME ="";


private SQLiteDatabase myDataBase;


private final Context myContext;


public DBAccess(Context context){


 super(context,DB_NAME,null,1);


 this.myContext=context;




}


public void createDataBase() throws IOException{


 SQLiteDatabase checkDB = null;


 try{


    String myPath = DB_PATH + DB_NAME;


    checkDB= SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS);




 }catch (SQLiteException e){




 }if(checkDB != null){


    checkDB.close();




 }


 boolean dbExist = checkDB != null ? true : false;


 if(dbExist){


    this.getReadableDatabase();


 }










반응형