android


Database sqlite android rewrite


In my android app, i create a sqlite database in onCreate() method and it is filled with informations that i get from a csv file on my server.
My problem is that everytime the app is launched, my db is filled with same information once again (so if the app is launched 3 times i will have my db filled 3 times with same data).
First launch:
ID NAME AGE ADDRESS SALARY
---------- ---------- ---------- ---------- ----------
1 Paul 32 California 20000.0
2 Allen 25 Texas 15000.0
Second:
ID NAME AGE ADDRESS SALARY
---------- ---------- ---------- ---------- ----------
1 Paul 32 California 20000.0
2 Allen 25 Texas 15000.0
1 Paul 32 California 20000.0
2 Allen 25 Texas 15000.0
Third:
ID NAME AGE ADDRESS SALARY
---------- ---------- ---------- ---------- ----------
1 Paul 32 California 20000.0
2 Allen 25 Texas 15000.0
3 Paul 32 California 20000.0
4 Allen 25 Texas 15000.0
5 Paul 32 California 20000.0
6 Allen 25 Texas 15000.0
How can i handle this situation? I would like that my db would be filled only if data in csv are not in the db.
Any idea?
Cursor cursor = mDB.rawQuery("select ID from TABLE where ID = 1;", null);
if(cursor.getCount()==0)
{
// now you can insert the record
}
else
{
// your handle
}

Related Links

eclipse android apk invalid
How to Build android native dialer application (Kitkat version) in Eclipse
Android emulator start slowly and lost from running devices
Correct way to track users and logout app
android sdk detecting emulator mode in java
Android Facebook Integeration
Wake-ups of cpu in android device
Listening to Intent beeing sent
Find which frame the current fragment is displayed in
How to get ID from insert()
Populate AWS Mobile Analytics Revenue graph
can i open an installed app with in my linear layout on a button click - Android Project
How to set Bitmap on ImageView using library Volley
Turning off keyboard animation for activity
How to get the primary email associated with the kindle fire account?
Sqlite - No Such Column Error while deleting table from sqlite_sequence

Categories

HOME
httparty
scikit-learn
hyperlink
interface
components
camera
apiblueprint
socket.io
rendering
rom
cq5
pyqt4
google-cloud-datalab
odoo-8
discrete-mathematics
spin
project
categorical-data
octave
google-chrome-app
rtf
stellar.js
radgridview
intercom
flash-player
magnetic-cards
feathersjs
smartclient
enterprise-miner
boost-icl
database-connection
breadth-first-search
springfox
ember-cli
ios10.2
tiki-wiki
itunes
gpio
has-and-belongs-to-many
spotipy
google-earth
aws-codecommit
angularjs-material
catch-unit-test
autolisp
fossil
lubridate
engine.io
reactivekit
recurrent-neural-network
google-data-api
p4merge
plaintext
watchface
dynamic-linq
robomongo
configurationmanager
ngmaterial
boo
type-theory
template-toolkit
vibrate
bootstrap-tags-input
branch-prediction
testrail
i386
android-dateutils
swizzling
lz77
thread-sleep
aspen
false-sharing
jparsec
toran-proxy
grgit
qt5.2
fiware-monitoring
lazybones
.bash-profile
atoi
keyup
canvg
ss7
lnk
gnumeric
file-not-found
git-repo
solace-mq
mysql-error-1044
isqlquery
ebay-lms
observium
cmmi
route-provider
android-icons
preload
wimax
qtconcurrent
cuda-gdb
luabind
matlab-load
google-ajax-api
pylucene
event-receiver
mtu
diagrams
interprocess
isapi-extension
pagemethods
strtod
google-wave
localizable.strings

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App