Reputation: 1464
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?
Upvotes: 2
Views: 2838
Reputation: 1007399
I saw that i can execute a .sql file with shell commands
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 on SQLiteDatabase
, perhaps wrapping them in your own transaction using beginTransaction()
and kin.
Upvotes: 2