android


Android DB: Merging Two Databases Using SQL Dumps


I'm currently working on the database part of a project where I have to merge the contents of two databases and I would like to ask you if there exists a simple API method
within the Android API/SDK itself that dumps me a database to a SQL text file.
Actually I found no hint in the API documentation about such an implementation myself. And I really doubt there is a single line method somewhere buried behind the curtain.
However I've already made a workaround using the sqlite3 shell tools of Android Linux by invoking:
String[] cmd = {"/system/bin/sh", "-c", ..., "sqlite3 ..."};
Runtime.getRuntime().exec( cmd );
Where I have two choices, a) pipe it directly to an output file or b) write the file using BufferedOutputStream.
Nevertheless, most likely due to compatibility issues am I asking you of a more convenient way within the API itself, rather than using the critical shell trick within the App.
I am also pretty much interested in any fast & pretty clues about merging two databases using Android's database methods.
Thanks.
There's nothing built in to the API that will help you. You could query, and write the INSERT statements yourself. There's a blog entry (http://mgmblog.com/2009/02/06/export-an-android-sqlite-db-to-an-xml-file-on-the-sd-card/) , on building an XML file from the results of your query. A few tweaks, and you coule build your own dump file.
You don't say what kind of merge you need to do, but you might be able to use ORMLite, by doing something like override the equals method on your model objects to compare the records and/or combine data from certain fields (assuming the schema is the same), without having to write a lot of SQL.

Related Links

Buttons getting cut off in landscape rotation (Android XML)
getSupportFragmentManager in Service,Android studio
Activity has leaked window com.android.internal.policy.PhoneWindow$DecorView{2d637e8 V.E… R… 0,0-768,293} that was originally added here
How sort recyclerview by data
Retrieving values from hashmap and sending to new activity
Retrofit List of object assigns null to data
“Cannot resolve method … ” after inserted app indexing by accident
How to create a Google Keep Style RecyclerView child item that has Checkboxes
Fill FirebaseRecyclerAdapter with data from more than one node
Continue playing videoview after interruption
How to Parse a Nested JSON response in Android
Searching Bluetooth Nearby in 6.0.1
Android textview and edit text data passing
How to make content provider visible to all users on tablet
java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions on Android API 15
How to load images from res/drawable-folder in ReactNative-App?

Categories

HOME
azure-stream-analytics
assembly
fpga
google-spreadsheet
ms-access-2016
spring-data-mongodb
tivoli
limit
code-coverage
google-cloud-datalab
discrete-mathematics
okhttp
alamofire
selenium-ide
shared-libraries
selectize.js
altera
capistrano3
mvc-mini-profiler
firefox-addon
dreamweaver
fileserver
forgot-password
sigma.js
sencha-touch
apache2.4
simpleitk
asciidoctor-pdf
ksh
imagemap
react-toolbox
mount
expressionengine3
shared
ms-access-web-app
oculus
handler
jaws
testcomplete
event-flow
wacom
openwhisk
imx6
salesforce-communities
connection-pool
p4merge
chef-solo
spring-mvc-test
ogc
visa
android-ibeacon
preloader
procfile
launchctl
lightning
aquamacs
wpas
subnet
avx
mathcad
stax
qtplugin
firebase-security
jtwig
phpwebsocket
aspen
state-restoration
decimalformat
tfs-workitem
themoviedb-api
skspritenode
nsurlsessiondatatask
node-serialport
zend-currency
cakephp-2.7
openbabel
uncaught-typeerror
sip-server
device-tree
insight.database
xml-namespaces
rcaller
vbe
koala
node-blade
os.system
inkcanvas
wiimote
google-maps-mobile
multiplatform
isapi-extension
wysiwym
int64

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