Copyright (c) 2014, KB Sriram
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. R...
If you think the Android project savemypics listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package org.savemypics.android.db;
//www.java2s.comimport android.content.Context;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase;
import android.database.SQLException;
publicfinalclass CDb
{
public CDb(Context ctx)
{ m_openhelper = new Helper(ctx); }
// We always use a writable database.
public SQLiteDatabase getDb()
{ return m_openhelper.getWritableDatabase(); }
publicfinalstaticvoid close(Cursor cursor)
{
if (cursor != null) { cursor.close(); }
}
privatefinal Helper m_openhelper;
privatefinalstaticclass Helper
extends SQLiteOpenHelper
{
privatefinalstatic String DB_NAME = "savemypics.db";
privatefinalstaticint DB_VERSION = 1;
private Helper(Context ctx)
{ super(ctx, DB_NAME, null, DB_VERSION); }
@Override
publicvoid onCreate(SQLiteDatabase db)
{
db.execSQL("pragma foreign_keys=on");
CAccount.makeSchema(db);
CMap.makeSchema(db);
CLocalImage.makeSchema(db);
CRemoteImage.makeSchema(db);
}
@Override
publicvoid onUpgrade(SQLiteDatabase db, int oldver, int newver)
{
thrownew IllegalStateException("unexpected version change");
}
/* api 11 @Override */publicvoid onDowngrade(SQLiteDatabase db, int oldver, int newver)
{
thrownew IllegalStateException("unexpected version downgrade");
}
}
}