PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 25 → [WINDEV MOBILE 19] Desativar integridade no SQLITE
[WINDEV MOBILE 19] Desativar integridade no SQLITE
Iniciado por pedrosao, fev., 21 2015 2:49 AM - Sem resposta
Membro registado
42 mensagems
Popularité : +7 (7 votes)
Publicado em fevereiro, 21 2015 - 2:49 AM
import android.database.sqlite.*;
import android.content.Context;
import android.util.*;
import android.database.*;
PUBLIC static string AtivarDesativarIntegridadeSQLite(string sTipo){
string DB_NAME = "O NOME DO SEU ARQUIVO.db";
string alterQuery = "";
SQLiteDatabase db;
try {
db = getContexteApplication().openOrCreateDatabase(DB_NAME, 0, null);
try {
IF (sTipo.toLowerCase() == "desativar"){
db.execSQL("PRAGMA synchronous = OFF;");
db.rawQuery("PRAGMA journal_mode = OFF;",null);
}
ELSE{
db.execSQL("PRAGMA synchronous = FULL;");
db.rawQuery("PRAGMA journal_mode = DELETE;",null);
}
db.close();
RETURN "ok";
} catch(SQLException e) {
db.close();
RETURN e.getMessage();
}
} catch (SQLException e) {
RETURN e.getMessage();
}
}

// USANDO NA SUA APLICAÇÃO
IF InAndroidSimulatorMode() = False THEN
sErro is string = AtivarDesativarIntegridadeSQLite("desativar")
IF sErro <> "ok" THEN
Error(sErro)
EndProgram()
END
ELSE
HExecuteSQLQuery(Query,Minhaconexao,hQueryWithoutCorrection,"PRAGMA synchronous = OFF;")
HExecuteSQLQuery(Query,Minhaconexao,hQueryWithoutCorrection,"PRAGMA journal_mode = OFF;")
END