I saw that i can execute a .sql file with shell commands…
Process process = Runtime.getRuntime().exec(commandLine);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
The “commandLine” attribute must be something like that?
commandLine = "sqlite> .read database.sql";
And another doubt… Where should i keep my “database.sql” file? Into assets? I’ve tryed to do that but not worked…
Someone knows how to do it?
That would be a really bad idea. There are no shell commands that are part of the Android SDK and therefore are guaranteed to be on all devices.
Read in the SQL script and execute its statements via
execSQL()and kin onSQLiteDatabase, perhaps wrapping them in your own transaction usingbeginTransaction()and kin.