Skip to content

Instantly share code, notes, and snippets.

@kdehairy
kdehairy / sql-statment-spliter.java
Last active December 15, 2015 23:19
Splits a sql script into an array of string statements
public String[] parseSqlFile( InputStream input ) throws IOException
{
BufferedReader reader = new BufferedReader( new InputStreamReader( input ) );
String line;
StringBuilder sql = new StringBuilder();
String multiLineComment = null;
while ( (line = reader.readLine()) != null ) {
// line = line.trim();
@kdehairy
kdehairy / Repository.java
Last active May 6, 2017 10:19
An implementation of SQLiteOpenHelper that uses a pre-loaded database file in android
public class Repository extends SQLiteOpenHelper {
private static final int VERSION = 1;
private static final String DATABASE_NAME = "data.sqlite";
private static File DATABASE_FILE;
// This is an indicator if we need to copy the
// database file.
private boolean mInvalidDatabaseFile = false;
private boolean mIsUpgraded = false;
private Context mContext;