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

How to provide the increment to textvale
How to pass image as url into arraylist using picaso library instead of drawable resource?
How to parse json with unknown key by Retrofit?
Android MS word and ContentProvider
Using view pager in recycler view row?
Getting the 3G signal strength in Android
onSaveInstanceState or SharedPreferences for multiple CheckBoxes?
Is there any way to change the device name in AdvertiseData in android BLE?
Pinterest Android app crashes when trying to share photo
how to create texviews one below one programatically?
AppBarLayout weird behavior with slidinguppanel (GIF)
Android Studio: Fixing gradle-wrapper and re-importing project is taking too long
Where does Android interpret the media button?
Genymotion error “specified virtual device was not found in VirtualBox list”
Test with specific device?
How to get current open activity package name or class name in setting like device administration in android 5 and above?

Categories

HOME
cygwin
gpu
jmx
themes
camera
error-handling
owl-carousel
cublas
scripting
emscripten
gembox-spreadsheet
x264
data-visualization
retrofit2
boto3
line
supervisor
eip
mvc-mini-profiler
easyphp
symfony-console
swagger-2.0
cgbitmapcontext
systemtime
postscript
aggregation
tiki-wiki
tpm
subclass
user-defined-functions
iis-express
jaws
twiml
ntp
boost-asio
wacom
hunspell
html-encode
numpy-broadcasting
openalpr
flatmap
unordered-map
signals-slots
portforwarding
claims
bindingnavigator
facebook-social-plugins
dapper-simplecrud
x++
jquery-ui-draggable
datamaps
convex-optimization
podscms
page-replacement
tinkerpop
semantic-logging
boxing
compiler-design
git-flow
filehandle
css-transforms
rxtx
structuremap4
rmongo
stax
flex-monkey
drawstring
dimension
database-relations
relativelayout
qtwebengine
cross-join
jbake
paw
imagefilter
angular-carousel
ignite-ui
parallel-testing
isqlquery
rolify
process-explorer
device-width
redis-py
josql
apache-whirr
ilasm
xcelsius
google-floodlight
escrow
fault-tolerance
application-planning
unmanagedresources
business-model

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