Galleries

Reading a .sql file for sqlite database

Hi

I am developing an andriod app and I have my data in .sql file downloaded via phpmyadmin.

Now there are some format difference in sql and sqlite3 commands. so I have performed the following steps to read the file in the format that is understandable by sqlite3 database

however make sure when you download the sql file from phpmyadmin, it should be MAXDB sql compatiblity mode. I have tested this, however it should also work on ANSI and DB2 compatiblity mode, but I have not used that
Also the settings shown in the image should be there when downloading the sql file

 

Here is the code which I used to read the sql file and populate it in sqlite3 database

private void fillData() {
DbHelper dh = new DbHelper(this);
SQLiteDatabase d = dh.getWritableDatabase();
String line;
String incompleteLine="";

try {
InputStream in = this.getAssets().open(“data.sql”);
if (in != null) {
// prepare the file for reading
InputStreamReader input = new InputStreamReader(in);
BufferedReader buffreader = new BufferedReader(input);

while ((line = buffreader.readLine()) != null) {
// Toast.makeText(this, line,Toast.LENGTH_LONG).show();
// d.execSQL(“INSERT INTO brand (_id,name,info) VALUES (‘2′,’AMICA’,’amica’);”);
// Print the content on the console
if (line.indexOf(“-“)==0 || line.indexOf(“/”)==0 || line.indexOf(“SET”)==0)
{
continue;
}

if (line.contains(“;”))
{
incompleteLine=incompleteLine+line;
System.out.println (incompleteLine);
d.execSQL(incompleteLine);
incompleteLine=””;

}
else
{
incompleteLine=incompleteLine+line;
}

}
in.close();
// Toast.makeText(this, res, Toast.LENGTH_LONG).show();
} else {
}
} catch (Exception e) {
Toast.makeText(this, e.toString() + e.getMessage(), 50000000).show();
}

d.close();

Intent selectBrandIntent = new Intent(this, SelectBrand.class);
startActivity(selectBrandIntent);
}

Advertisements

Configuration of TortoiseSVN after Installation

Hi

I am writing this blog because I found no proper tutorial for configuration of TortoiseSVN after it has been installed. Here is the step by step procedure with screen shots. Also with help of this you can also set up your repository somewhere in server.

First Install the latest version of  tortoiseSVN from http://tortoisesvn.net/downloads. I am using version 1.6.10 on my Windows 7  (64 bi t) machine

Step 1: Right click on Desktop and you can see the SVN item as follows

Step 2: Create a repository somewhere . If you are creating it on the server, make sure the folder is mapped in on the system. Also create a folder within the folder and then map the outer folder to the system. This eases the task when import the repo

After creating repository, following folders should be visible

Step 3: If your folder is somewhere on the sever, better to map the server by following steps

Go to my computer and from tools Menu click to map the drive and map the folder where you just created the repository

Step4: Now Create a tmp folder and create a new folder within it.

In the New cretate the following 3 folders

  • branches
  • tags
  • trunk

Step 5: Copy the project files from your main project (this is usually the local copy of files which are on your system; which you want to be versioned  to this trunk folder..

Step 6: Now right click in the trunk folder and click Import, locate the folder we created for Repository on the server (or to the location if you are not using server) and then click ok

Step 7:  Now Go to your local project location and click on SVNCheckout. Locate the repository location and click OK

Warning: When you hit OK it might produce the following warning that target folder is not empty , click yes, this will simply version your files. Just make sure you these are the same files which we copied in trunk.