PROFESSIONAL NEWSGROUPS
WINDEV
,
WEBDEV
and
WINDEV Mobile
Home
|
Recent messages
|
Connect
|
Sign out
|
English
Home
→
WINDEV Mobile 2024
→
Usando SQLite no Windev e Android
Usando SQLite no Windev e Android
Started by Carlos Leandro, Jun., 01 2015 6:22 PM - 2 replies
Connect yourself…
Carlos Leandro
#1
Posted on June, 01 2015 - 6:22 PM
Boa tarde pessoal, estou desenvolvendo uma aplicação para rodar no android ela usa o sqlite como banco de dados, no emulador eu criei todas as tabelas e as preenchi, no emulador ela funciona normal, quando eu vou gerar o apk eu coloco a tabela como integrante do apk, mas quando testo no meu celular ele diz que não encontra o banco.
Andei dando uma pesquisada e vi o Pedrosao e o Adriano falando sobre integridade do banco, isto tem haver com a minha dificuldade?
Grato.
Report
0
0
adrianoboller
#2
Registered member
3,661 messages
Popularité : +175 (223 votes)
Posted on September, 11 2015 - 7:15 AM
http://forum.pcsoft.fr/fr-FR/pcsoft.us.windevmobile/598-initialize-database-sqlite-windev-mobile-android/read.awp…
--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
______________________________________________
Report
0
0
BOLLER ADRIANO
#3
Registered member
3,661 messages
Popularité : +175 (223 votes)
Posted on August, 10 2016 - 4:58 AM
Função JAVA:
import android.database.sqlite
.
*
;
import android.content.Context
;
import android.util
.
*
;
import android.database
.
*
;
PUBLIC static string
AtivarDesativarIntegridadeSQLite
(
string
s
Tipo
)
{
string
DB_NAME
=
"O NOME DO SEU ARQUIVO.db"
;
string
alterQuery
=
""
;
SQLiteDatabase db
;
try
{
db
=
getContexteApplication
(
)
.
openOrCreateDatabase
(
DB_NAME
,
0
,
null
)
;
try
{
IF
(
s
Tipo.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
(
)
;
}
}
Utilizando a função no seu aplicativo:
IF
InAndroidSimulatorMode
(
) =
False
THEN
s
Erro is
string
=
AtivarDesativarIntegridadeSQLite
(
"desativar"
)
IF
s
Erro
<
>
"ok"
THEN
Error
(
s
Erro
)
EndProgram
(
)
END
ELSE
HExecuteSQLQuery
(
Query
,
Minhaconexao
,
hQueryWithoutCorrection
,
"PRAGMA synchronous = OFF;"
)
HExecuteSQLQuery
(
Query
,
Minhaconexao
,
hQueryWithoutCorrection
,
"PRAGMA journal_mode = OFF;"
)
END
--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Report
0
0
→ Go back to WINDEV Mobile 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (earlier versions)
Français
English
Español
Portuguesa
Close this window
Search type
Only topics
All the messages
Search period
Any time
Past hour
Past 24 hours
Past week
Past month
Past year
Cancel
Preview of your message
Adding an image
Import an image from a URL
Send an image from a file of your disk
Drop a file or click "Browse..."
or
Cancel
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Text