Back to project page droidkit-engines.
The source code is released under:
MIT License
If you think the Android project droidkit-engines listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.droidkit.engine.keyvalue.sqlite.internal; /*from ww w .ja va2s. c o m*/ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteStatement; import com.droidkit.engine._internal.sqlite.SqlStatements; public class KeyValueEngineTableStatements implements SqlStatements { private final SQLiteDatabase db; private final String tablename; private SQLiteStatement insertStatement; private SQLiteStatement insertOrReplaceStatement; private SQLiteStatement updateStatement; private SQLiteStatement deleteStatement; private String getByIdStatement; private String allStatement; public KeyValueEngineTableStatements(SQLiteDatabase db, String tablename) { this.db = db; this.tablename = tablename; } public SQLiteStatement getInsertStatement() { if (insertStatement == null) { String sql = String.format("INSERT INTO '%s' (ID,BYTES) VALUES (?,?)", tablename); insertStatement = db.compileStatement(sql); } return insertStatement; } public SQLiteStatement getInsertOrReplaceStatement() { if (insertOrReplaceStatement == null) { String sql = String.format("INSERT OR REPLACE INTO '%s' (ID,BYTES) VALUES (?,?)", tablename); insertOrReplaceStatement = db.compileStatement(sql); } return insertOrReplaceStatement; } public SQLiteStatement getDeleteStatement() { if (deleteStatement == null) { String sql = String.format("DELETE FROM '%s' WHERE ID=?", tablename, tablename); deleteStatement = db.compileStatement(sql); } return deleteStatement; } public String getGetByIdStatement() { if(getByIdStatement == null) { getByIdStatement = String.format("SELECT * FROM '%s' WHERE ID=?", tablename); } return getByIdStatement; } public String getAllStatement() { if(allStatement == null) { allStatement = String.format("SELECT * FROM '%s'", tablename); } return allStatement; } }