Package org.greenrobot.greendao
Class DbUtils
- java.lang.Object
-
- org.greenrobot.greendao.DbUtils
-
public class DbUtils extends java.lang.ObjectDatabase utils, for example to execute SQL scripts
-
-
Constructor Summary
Constructors Constructor Description DbUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcopyAllBytes(java.io.InputStream in, java.io.OutputStream out)Copies all available data from in to out without closing any stream.static intexecuteSqlScript(android.content.Context context, Database db, java.lang.String assetFilename)CallsexecuteSqlScript(Context, Database, String, boolean)with transactional set to true.static intexecuteSqlScript(android.content.Context context, Database db, java.lang.String assetFilename, boolean transactional)Executes the given SQL asset in the given database (SQL file should be UTF-8).static intexecuteSqlStatements(Database db, java.lang.String[] statements)static intexecuteSqlStatementsInTx(Database db, java.lang.String[] statements)static voidlogTableDump(android.database.sqlite.SQLiteDatabase db, java.lang.String tablename)static byte[]readAllBytes(java.io.InputStream in)static byte[]readAsset(android.content.Context context, java.lang.String filename)static voidvacuum(Database db)
-
-
-
Method Detail
-
vacuum
public static void vacuum(Database db)
-
executeSqlScript
public static int executeSqlScript(android.content.Context context, Database db, java.lang.String assetFilename) throws java.io.IOExceptionCallsexecuteSqlScript(Context, Database, String, boolean)with transactional set to true.- Returns:
- number of statements executed.
- Throws:
java.io.IOException
-
executeSqlScript
public static int executeSqlScript(android.content.Context context, Database db, java.lang.String assetFilename, boolean transactional) throws java.io.IOExceptionExecutes the given SQL asset in the given database (SQL file should be UTF-8). The database file may contain multiple SQL statements. Statements are split using a simple regular expression (something like "semicolon before a line break"), not by analyzing the SQL syntax. This will work for many SQL files, but check yours.- Returns:
- number of statements executed.
- Throws:
java.io.IOException
-
executeSqlStatementsInTx
public static int executeSqlStatementsInTx(Database db, java.lang.String[] statements)
-
executeSqlStatements
public static int executeSqlStatements(Database db, java.lang.String[] statements)
-
copyAllBytes
public static int copyAllBytes(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOExceptionCopies all available data from in to out without closing any stream.- Returns:
- number of bytes copied
- Throws:
java.io.IOException
-
readAllBytes
public static byte[] readAllBytes(java.io.InputStream in) throws java.io.IOException- Throws:
java.io.IOException
-
readAsset
public static byte[] readAsset(android.content.Context context, java.lang.String filename) throws java.io.IOException- Throws:
java.io.IOException
-
logTableDump
public static void logTableDump(android.database.sqlite.SQLiteDatabase db, java.lang.String tablename)
-
-