Month: July 2011

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);
}

CONFIRM DELETE BOX IN PHP PAGE in ONE LINE

This was really quite hard for me to get this working but today finally I made it. If you are having problem in creating a confirm delete box directly from php page without any extended java script here is the script for you. For this basically you need to merge the php and HTML and then it works perfectly fine. My Experience says that you php only for logic and more of HTML for display
Here is my code

<a href="javascript:if (confirm('SURE YOU WANNA DELETE?')){window.location.href='index.php?option=com_enggaccount&task=removepostcodefromregion&engg_id=&postcode_id=' } else { void('') }; ">Delete