Sunday, 8 December 2013

How to store and access data from SQL Database using Android without using sqlite

Here one example is given in which i am storing the data into SQL database from Android and also can Display the Data in  Android App from SQL

We are using JSON here because  It is very useful and it makes easy our work which is actually very difficult without JSON.

JSON (JavaScript Object Notation) is a lightweight data exchange format inspired by JavaScript object
literals. It is often used with JavaScript, Ajax, and RESTful web services but is completely language independent.

temp.php

<?php
mysql_connect("localhost","root","");
mysql_select_db("tempdb");
$name=$_REQUEST["firstname"];
$lname=$_REQUEST["lastname"];
$query="insert into tbl_student values(NULL,'".$name."','".$lname."')";
mysql_query($query);
?>

select.php

<?php
mysql_connect("localhost","root","");
mysql_select_db("tempdb");
$query="select * from tbl_student";
$resultset=mysql_query($query);
while($row=mysql_fetch_assoc($resultset))
{
$output[]=$row;
}
print(json_encode($output));
?>

MainActivity.java

public class MainActivity extends Activity {

String result = null;
InputStream is = null;
StringBuilder sb = null;

int ct_id;
String[] ct_name = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);

// http post
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.2.2/mittal/select.php");
// httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error in http connection" + e.toString());
}

// convert response to string
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
sb = new StringBuilder();
sb.append(reader.readLine() + "\n");
String line = "0";
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result = sb.toString();
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}

// paring data
JSONArray jArray;
try {
jArray = new JSONArray(result);
JSONObject json_data = null;
ct_name = new String[jArray.length()];
for (int i = 0; i < jArray.length(); i++) {
json_data = jArray.getJSONObject(i);
ct_id = json_data.getInt("student_id");
ct_name[i] = json_data.getString("student_name")+" "+json_data.getString("student_sname");
}
} catch (JSONException e1) {
Toast.makeText(getBaseContext(), "No City Found", Toast.LENGTH_LONG)
.show();
} catch (ParseException e1) {
e1.printStackTrace();
}

ListView lv=(ListView)findViewById(R.id.listView1);
ArrayAdapter<String> lvadptr=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,ct_name);
lv.setAdapter(lvadptr);

// insert code start
Button btn=(Button)findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
EditText et1=(EditText)findViewById(R.id.editText1);
EditText et2=(EditText)findViewById(R.id.editText2);
String fname=et1.getText().toString();
String lname=et2.getText().toString();

ArrayList<NameValuePair> namevaluepairs=new ArrayList<NameValuePair>();
namevaluepairs.add(new BasicNameValuePair("firstname", fname));
namevaluepairs.add(new BasicNameValuePair("lastname", lname));

try
{
HttpClient httpclient=new DefaultHttpClient();
HttpPost httppost=new HttpPost("http://10.0.2.2/mittal/temp.php");
httppost.setEntity(new UrlEncodedFormEntity(namevaluepairs));

HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();

Intent newint=new Intent(getApplicationContext(), MainActivity.class);
startActivity(newint);

}
catch(Exception e)
{
Log.d("myerror", e.toString());
}
}
});
//insert code end
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}

Friday, 22 November 2013

Data Flow Diagrams for Online Shopping Website

(Click on Diagram to see full view of Diagram)
Level 0
(Click on Diagram to see full view of Diagram)



Level 1
(Click on Diagram to see full view of Diagram)


Level 2 for 2.0
(Click on Diagram to see full view of Diagram)



Level 2 for 4.0
(Click on Diagram to see full view of Diagram)



Level 2 for 5.0
(Click on Diagram to see full view of Diagram)



Level 3 for 4.3
(Click on Diagram to see full view of Diagram)

Thursday, 12 September 2013

Activity Diagram for Admin in Online Shopping website





Thursday, 13 June 2013

Fences app that organize your desktop.

friends now its time to organize to tidy and clustered desktop and it is categorized your desktop and sort as you want.

Fences is a brand new toolbar for sorting and un-cluster your desktop.The fences look the same - they're clean and blend well, and you can adjust the transparency and color to suit your needs. You'll also still be able to easily sort your files and program icons into multiple fences on your desktop. One of our favorite features, Auto-Organizer, also lets you choose which files will automatically go into the fence you specify--this is handy if you frequently add new files to your computer. 

you can download fences toolbar from below link.

click here for download

enjoy sorting your desktop.

Now converting video format is child's play..!!

if you want to convert a video in one format to another format than now it is child's play friends.you should first download a Handbrake video converter.This video converter accepts practically all the format of the video as a source and it also includes chapter selection, basic subtitle support and audio embedding. With tree diagrams and tabs in the interface, Handbrake is a pleasure to use. 

you can download Handbrake form below link.

click here for download Handbrake



friends use this and enjoy converting.
share with us your experience.

Monday, 10 June 2013

Girls wanna know how can you make Messy Braided Bun??

Girls would like to like make Messy Braided Bun on your hair for any traditional occasion??then follow this steps and get ready for your party and events.


Girls if make this Bun then comment your experience please and upload your pic with this hair style.


"Home truths on career wives" one of the best article of Chetan Bhagat related to Cocktail Movie

Home truths on career wives

below article is written by Chetan Bhagat and published on The Times of India too.


Recently, I saw the recently released movie,Cocktail. The plot revolves around a philanderer hero who has to make the tough choice between two hot women. The uber-modern movie was set in London. The characters drank, danced in nightclubs and had one-night stands with aplomb. They worked in new-age inspirational jobs like glamour photography, graphic art and software design. And yet, the guy eventually chooses the girl who cooks home food, dresses conservatively, wins his mother's approval and is happy to be the ideal Indian wife. In fact, even the rejected girl, a free-spirited, independent woman agrees to change herself. To get the guy, she is happy to cook and change her lifestyle to match that of the ideal Indian wife. 


While the movie was fun, such depictions disturb me a little. When successful, strong women are portrayed as finding salvation in making dal and roti for their husbands, one wonders what kind of India we are presenting to our little girls. 
Really, is that what a woman's life is all about — to make hot phulkas? Of course, i shouldn't be so bothered, many would say. It is a Bollywood movie. The commercial pressure to present a palatable story is real. Above all, the makers have a right to tell the narrative they want. 
Yet, when our most modern and forward cinema sinks into regressive territory, it is unfair to our women. It is also depressing because deep down we know such attitudes exist. Many Indian men, even the educated ones, have two distinct profiles of women — the girlfriend material and the wife material. One you party with, the other you take home. The prejudice against non-traditional women who assert themselves is strong. 
Let us look at another part of the world. Yahoo, a leading tech firm and a Fortune 500 company, recently hired a new woman CEO, Marissa Mayer. What's more, she was six months pregnant when she was hired, a fact she did not hide in her interviews. 
Marissa will take some time off after childbirth and will be back at work later. She can manage both. There is something to celebrate about that. Marissa is a role model for women and even men. 
I'd like Indian men to have an open mind about choosing their life partners and revise their 'ideal woman' criteria. Having a traditional wife who cooks, cleans and is submissive might be nice. However, choosing a capable, independent and career-oriented woman can also bring enormous benefits. For instance, one, a man who marries a career woman gets a partner to discuss his own career with. A working woman may be able to relate better to organizational issues than a housewife. A spouse who understands office politics and can give you good advice can be an asset. Two, a working woman diversifies the family income streams. In the era of expensive apartments and frequent lay-offs, a working spouse can help you afford a decent house and feel more secure about finances. Three, a working woman is better exposed to the world. She brings back knowledge and information that can be useful to the family. Whether it's the latest deals or the best mutual fund to invest in, or even new holiday destinations, a working woman can add to the quality of life. Four, the children of a working woman learn to be more independent and will do better than mollycoddled children. Five, working women often find some fulfillment in their jobs, apart from home. Hence, they may have better life satisfaction, and feel less dependent on the man. This in turn can lead to more harmony. Of course, all these benefits accrue if men are able to keep their massive, fragile egos aside and see women as equals. 
Sure, there are drawbacks also in being with working women. But the modern age that we are in, the phulka-making bride may come at a cost of missing out on other qualities. Please bear that in mind before you judge women based on their clothes, interest in the kitchen or the confidence in their voice. 
My mother worked for 40 years. My wife is the COO at an international bank. It makes me proud. She doesn't make phulkas for me. We outsource that work to our help, and it doesn't really bother me. If my wife had spent her life in the kitchen, it would have bothered me more. 
Please choose your partner carefully. Don't just tolerate, but accept and even celebrate our successful women. They take our homes ahead and our country forward. We may have less hot phulkas, but we will have a better nation.