Include database data when exporting an Android application - database

I export my application to .apk file, sign it and then install it. But when I run my app, it displays an error because there's no data in my database.
The database was created as a new one when I installed the application, so all the data were lost!
How can I include database data when exporting an Android application?

Option #1: Package the database as a raw resource or asset, and use streams to copy that database to its proper position when the app is first run.
Option #2: Package SQL statements to populate the database as a raw resource, and execute those statements in your SQLiteOpenHelper's onCreate() method.
Option #3: Put the smarts straight in your Java code to populate your database in your SQLiteOpenHelper's onCreate() method.
Option #4: Download the database on first run and copy it to its proper position.
And so on.

Related

Neo4j - Importing a Database of fraud detection

Hello i'm trying to deploy the Fraud Detection Use case that was shared in NEO4j use cases
Following this link: https://neo4j.com/graphgist/credit-card-fraud-detection
To get deeper in the data I want to work with the database that was shared in the link
https://www.dropbox.com/s/4uij4gs2iyva5bd/credit%20card%20fraud.zip
I don't know how to load it since there is no .csv file just .db with the same structure of system and neo4j Databases,
I have tried to create a Database and connect it to the path of the fraud detection file,
Anyone can help me please to work with this database
If you are using Neo4j Desktop:
Go to the management tab of your graph
Click "Open terminal"
Locate the folder data/databases/
Copy the content of the folder you downloaded from Dropbox into data/databases/fraud.db
Back to the management tab, go to the settings tab and identify the line:
#dbms.active_database=graph.db
Change this line to:
dbms.active_database=fraud.db
Restart your database
In case of error, go back to the settings and uncomment:
#dbms.allow_upgrade=true

2 Separate DACPAC files for test and production

I have a VS2015 database project (sqlproj) and I created a lot of test data. I added a parameter to the PostDeploymentScript.sql file and when I need an empty database, I set it false and when I publish it doesn't include test data. When I need a demo database I set it true and when I publish, it also adds test data after deployment.
On the other hand, I want to create two different DACPAC files to prevent manual process and build both of them automatically at once. I searched a little bit and found several articles like this:
http://www.techrepublic.com/blog/data-center/auto-deploy-and-version-your-sql-server-database-with-ssdt/
but I couldn't apply what he said. What am I missing?
I created an (almost) empty database project (Lets say Base.sqlproj) which adds lookup table data after deployment. I created another DB project (Base_Plus_TestData.sqlproj) and added a database reference for the first database.
What I need is, if client needs to deploy empty database I'd like to give them the Base.DACPAC. If client needs to deploy a demo database with test data, I want to give them Base_Plus_TestData.DACPAC.
What should I do for this purpose and what am I doing wrong?
There a couple of extra options over what you already do with a switch to include data, I would choose the first :)
1 - Just give customers who want demo data a script to run after deploying the database (you could do something like use a powershell script/.net app to deploy your data and optionally the data)
2 - The post deploy script can be edited in a dacpac, you could build your project, copy the dacpac and then edit the post deploy script to include your data on one of the dacpacs.
3 - Create a separate ssdt project that references your main database project with a "same database" reference and the extra post deploy script - wheb you build you will get two dacpacs you can deploy either together if you want data or just the database.
If you also have data in your original dacpac to deploy you will need to copy it into the "with data" dacpac.
Ed

add data to a *.sdf file

I have create an application for windows, where i am using phone's sqlite as DB to store data. While testing the app in Emulator after the first time(i.e reinstallion of the app), the data of the DB gets erased every time.
So can any one please tell me How to:
Save the existing data of the DB before reinstalling the app.
Modify the .sdf file Manually (with out using the app)
To save the data in some other way, which will not be affected by the reinstallation of the app.
More Information regarding ways to add data to .sdf file are appreciated ...
Edit: Is it possible to browse and edit the .sdf file in phone when application gets installed
If you run the app via the Emulator, every time you close the emulator the app along with its components gets uninstalled. To prevent this , don't close the emulator everytime you run the app. Keep the emulator open, and run the program.
In the phone once the app is installed, the data is not deleted from the database and it is persisted.
The SDF can be modified using the Server Explorer in Visual Studio, add a database connection to SQL CE 3.5 and point to your sdf. You can modify the data from there.
You can also use the Isolated Storage explorer to open the SDF. http://wp7explorer.codeplex.com/

Create MySQL database on server

I'm following a tutorial for constructing a PHP and MySQL ecommerce driven website, and I'm uploading them to my server at the moment, but in need of some assistance determining how to proceed.
In the README of the tutorial, are the following instructions:
INSTALLATION INSTRUCTIONS
1.) Unzip plaincart.zip to the root folder under your
HTTP directory ( or under your preferred directory)
2.) Create a database and database user on your web
server for Plaincart
3.) Use the sql dump in plaincart.sql to generate the
tables and example data
4.) Modify the database connection settings in
library/config.php.
5.) If you want to accept paypal modify the settings
in include/paypal/paypal.inc.php . More information
about this paypal stuff can be found in
http://www.phpwebcommerce.com/shop-checkout-process/
OK, so I obviously am capable enough to complete #1! :)
So, on to number 2, how to I create a database on my server?
I understad number 3, referring to the fact that I use the SQL dump file to construct some sample data once the database has been created.
I can't tell about #4 and #5 yet, but we'll see when we get there.
So, I guess I just need to know how to construct a MySQL database on my web server.
Easiest way: install phpmyadmin on the remote server, and do it from that web interface.

Is there a way to easily change the server name on several SSIS packages programmatically?

We are creating several SSIS packages to migrate a large database as part of a release cycle.
We may end up with about 5-10 SSIS packages.
As we have 4 environments (dev, QA, staging, production, etc.), is there an efficient way to change the destination server for each SSIS package as they go through the different server environments? Ideally, there could be a script that is run that would take as a parameter the server that was needed.
You could use a configuration file to store the connection strings for the servers. Then as you moved from environment to environment, you would simply change the config file. To simply create a config file, on the control surface of your package,
1) right click and choose Package Configurations from the context menu.
2) Check the box for Enable package configurations if it is not already selected,
3) then Click the Add... button.
4) Click next on the dialog,
5) then add a Configuration file name: and click next.
6) In the Objects View, Under Connection Managers, expand your connection, then expand Properties and check the box next to ConnectionString.
7) Then click next
8) then finish.
You now have an xml file named what you named it in step 5 above. You can edit this file with a text editor and change the connection string to map to whichever server you need it to before each run.
Once created you can share the config file between multiple packages as long as the objects referenced are named the same between the packages.
This is a rudimentary tutorial on configurations, there are many ways of saving configurations of which this is only one. For more information on configurations consult your favorite SSIS book
We use a config table that stores the configurations for the server. But config files work well too. We like the table because we are doing reporting on SSIS package meta data and it's easier to grab this data (along with a lot of other data we store as well) when stored in a table.
William Todd Salzman's answer covers most points. I have a couple more to add:
Make sure the pacakge ProtectionLevel property is DontSaveSensitive
If you are working with different shipping environments, then a SQL Server table as a source for the package configurations is maybe not for you, as you will require one central database containing all the connection strings for all the servers.
Having worked with package configurations retrieved from the registry, you will need to be aware that these settings are retrieved from the HKEY_CURRENT_USER hive. This has implications for when the package is run through a SQL Agent Job.

Resources