Just installed the new 0.9r and I have a bit of a problem with my Database.
This is my code:
Using java Syntax Highlighting
- public class NewsDatabase {
- private static final String CREATE_TABLE_SITES = "create table sites (site_id integer primary key autoincrement, "
- + "title text not null, url text not null);";
- private static final String CREATE_TABLE_NEWS = "create table news (news_id integer primary key autoincrement, "
- + "site_id int not null, title text not null, url text not null, data text not null);";
- private static final String SITES_TABLE = "sites";
- private static final String NEWS_TABLE = "news";
- private static final String DATABASE_NAME = "iNewspaper";
- private static final int DATABASE_VERSION = 1;
- private static final String TAG = "NewsDatabase";
- private SQLiteDatabase db;
- public NewsDatabase(Context ctx){
- try {
- db = ctx.openDatabase(DATABASE_NAME, null);
- } catch (FileNotFoundException e) {
- try {
- db = ctx.createDatabase(DATABASE_NAME, DATABASE_VERSION, 0, null);
- db.execSQL(CREATE_TABLE_SITES);
- db.execSQL(CREATE_TABLE_NEWS);
- } catch (FileNotFoundException e1) { db = null;}
- }
- }
Parsed in 0.054 seconds, using GeSHi 1.0.8.4
So apparently db = ctx.openDatabase(DATABASE_NAME, null);
Does not work any more and has been changed to OpenOrCreateDatabase.
As well as db = ctx.createDatabase(DATABASE_NAME, DATABASE_VERSION, 0, null);
But how can you distinguish the both.
First open and then if not created create with the given SQL.
I do not want to use SqliteOpenHelper cause all of my methods and such are already done.
I just would like to know HOW can you open/create a SQLite db in the new release 0.9.
Thanks for your help!
Cheers






