If you think the Android project LyricHere 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 cn.zhaiyifan.lyrichere.db;
/*fromwww.java2s.com*//**
* Created by yifan on 6/3/14.
*/import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import cn.zhaiyifan.lyrichere.Constants;
import cn.zhaiyifan.lyrichere.utils.Util;
publicclass DbHelper extends SQLiteOpenHelper {
privatestaticfinal String TAG = DbHelper.class.getSimpleName();
public DbHelper(Context context) {
super(context, Constants.DB_NAME, null, Constants.DB_VERSION);
}
// DROP TABLE IF EXISTS lyric;
@Override
publicvoid onCreate(SQLiteDatabase db) {
String sql = String.format("create table %s (%s INTEGER PRIMARY KEY AUTOINCREMENT, " +
"%s TEXT, %s TEXT, %s TEXT, %s INT, %s TEXT, %s TEXT, %s INT, %s INT)",
Constants.TABLE,
Constants.Column.ID,
Constants.Column.TITLE,
Constants.Column.ARTIST,
Constants.Column.ALBUM,
Constants.Column.LENGTH,
Constants.Column.PATH,
Constants.Column.ENCODING,
Constants.Column.ENCODING_CHANGED,
Constants.Column.LAST_VISITED_AT);
Util.log(TAG, "onCreate with SQL: " + sql);
db.execSQL(sql);
}
// Gets called whenever existing version != new version, i.e. schema changed
@Override
publicvoid onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Typically you do ALTER TABLE ...
db.execSQL("drop table if exists " + Constants.TABLE);
onCreate(db);
}
}