mercredi 4 mars 2015

Error in executing sqlite program

Unfortunately my app stopped working. please help me.I tried my level best in finding what went wrong but unluckily couldn't figure it out. This is my code. package com.example.bostonvids2;



import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class sqliteexample extends Activity implements OnClickListener
{
Button bsqlupdate,bsqlopenview;
EditText etsqlname,etsqlhotness;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.sqliteexample);
etsqlname=(EditText)findViewById(R.id.etsqlname);
etsqlhotness=(EditText)findViewById(R.id.etsqlhotness);
bsqlupdate.setOnClickListener(this);
bsqlopenview.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId())
{
case R.id.bsqlupdate:
boolean diditwork=true;
try{
String name=etsqlname.getText().toString();
String hotness=etsqlhotness.getText().toString();
hotornot entry=new hotornot(sqliteexample.this);
entry.open();
entry.createentry(name,hotness);
entry.close();
}catch(Exception e){
diditwork=false;
String error=e.toString();
Dialog dia=new Dialog(this);
dia.setTitle("oh my god!");
TextView tv=new TextView(this);
tv.setText(error);
dia.setContentView(tv);
dia.show();
}finally
{
if(diditwork)
{
Dialog dia=new Dialog(this);
dia.setTitle("Heck Yea!");
TextView tv=new TextView(this);
tv.setText("Success");
dia.setContentView(tv);
dia.show();
}
}
break;
case R.id.bsqlopenview:
Intent i=new Intent("com.example.bostonvids2.SQLVIEW");
startActivity(i);
break;
}
}


}


this is my xml:



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name" />

<EditText
android:id="@+id/etsqlname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" >

<requestFocus />
</EditText>

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hotness scale 1 to 100" />

<EditText
android:id="@+id/etsqlhotness"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" />



<Button
android:id="@+id/bsqlupdate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="update SQLite database" />

<Button
android:id="@+id/bsqlopenview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="view" />

</LinearLayout>


this is my manifest file.



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://ift.tt/nIICcg"
package="com.example.bostonvids2"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.bostonvids2.background"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".MainActivity"
android:label="@string/app_name" >

</activity>
<activity
android:name=".Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.bostonvids2.MENU" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".about"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog">
<intent-filter>
<action android:name="com.example.bostonvids2.ABOUT" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".prefs"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="com.example.bostonvids2.PREFS" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".sqliteexample"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.bostonvids2.SQLITEEXAMPLE" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".sqlview"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="com.example.bostonvids2.SQLVIEW" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".align"
android:label="@string/app_name" >
</activity>
<activity
android:name=".email"
android:label="@string/app_name" >
</activity>
<activity
android:name=".camera"
android:label="@string/app_name" >
</activity>
<activity
android:name=".bmpstream"
android:label="@string/app_name" >
</activity>
<activity
android:name=".interintent"
android:label="@string/app_name" >
</activity>
<activity
android:name=".openclas"
android:label="@string/app_name" >
</activity>
<activity
android:name=".openclas2"
android:label="@string/app_name" >
</activity>
<activity
android:name=".interintent2"
android:label="@string/app_name" >
</activity>
<activity
android:name=".GFX1"
android:label="@string/app_name" >
</activity>
<activity
android:name=".ani1"
android:label="@string/app_name" >
</activity>
<activity
android:name=".clicsound"
android:label="@string/app_name" >
</activity>
<activity
android:name=".tabs"
android:label="@string/app_name" >
</activity>
<activity
android:name=".simplebrowser"
android:label="@string/app_name" >
</activity>

<activity
android:name=".hotornot"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.bostonvids2.HOTORNOT" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>

</manifest>

Aucun commentaire:

Enregistrer un commentaire