Click here to Skip to main content
15,895,370 members
Home / Discussions / Android
   

Android

 
AnswerRe: android compilation problem on lower version devices Pin
Richard MacCutchan13-Aug-15 1:05
mveRichard MacCutchan13-Aug-15 1:05 
GeneralRe: android compilation problem on lower version devices Pin
Member 1190643213-Aug-15 2:35
Member 1190643213-Aug-15 2:35 
GeneralRe: android compilation problem on lower version devices Pin
Richard MacCutchan13-Aug-15 4:15
mveRichard MacCutchan13-Aug-15 4:15 
AnswerRe: android compilation problem on lower version devices Pin
David Crow13-Aug-15 5:52
David Crow13-Aug-15 5:52 
AnswerRe: android compilation problem on lower version devices Pin
Siddharth Chandra24-Aug-15 6:09
Siddharth Chandra24-Aug-15 6:09 
QuestionDraggable Button in Xamarin.Android ? Pin
Vaikesh K P11-Aug-15 0:20
professionalVaikesh K P11-Aug-15 0:20 
AnswerRe: Draggable Button in Xamarin.Android ? Pin
Richard MacCutchan11-Aug-15 5:42
mveRichard MacCutchan11-Aug-15 5:42 
QuestionI have table not found in SQLite database table. Pin
Member 1141933410-Aug-15 22:19
Member 1141933410-Aug-15 22:19 
Here is my logcat:
08-11 13:40:18.540 15571-15571/com.test.krunal.test E/SQLiteLog﹕ (1) no such table: mydb
08-11 13:40:18.547 15571-15571/com.test.krunal.test E/SQLiteDatabase﹕ Error inserting name=krunal dates=2015-08-11 01:39:56 mobno=7878879383 mailid=abc@abc.com bday=03/08/1994
android.database.sqlite.SQLiteException: no such table: mydb (code 1): , while compiling: INSERT INTO mydb(name,dates,mobno,mailid,bday) VALUES (?,?,?,?,?)



Here is my DatabaseHelper.java file

package com.test.krunal.test;


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import java.sql.SQLException;


public class DatabaseHelper {
public static final String KEY_ROWID="_id";
public static final String KEY_NAME="name";
public static final String KEY_BDAY="bday";
public static final String KEY_MOBNO="mobno";
public static final String KEY_MAIL="mailid";
public static final String KEY_DATE="dates";

private static final String DATABASE_NAME="mydb";
private static final String DATABASE_TABLE="mytable";
private static final int DATABASE_VERSION=1;

private DbHelper ourhelper;
private Context ourcontext;
private SQLiteDatabase ourdatabase;


public DatabaseHelper(Context c){
ourcontext=c;
}
public DatabaseHelper open() throws SQLException{
ourhelper = new DbHelper(ourcontext);
ourdatabase= ourhelper.getWritableDatabase();
return this;
}

public long createentry(String name, String bday, String mobno, String mail, String dater) {
ContentValues cv=new ContentValues();
cv.put(KEY_NAME,name);
cv.put(KEY_BDAY,bday);
cv.put(KEY_MOBNO,mobno);
cv.put(KEY_MAIL, mail);
cv.put(KEY_DATE, dater);
return ourdatabase.insert(DATABASE_NAME,null,cv);
}
public void close() {
ourhelper.close();
}
public String getdata() {
String[] columns=new String[]{KEY_NAME,KEY_BDAY,KEY_MOBNO,KEY_MAIL,KEY_DATE};
Cursor c=ourdatabase.query(DATABASE_TABLE, columns, null, null, null, null, null);
String result="";
int iName= c.getColumnIndex(KEY_NAME);
int iBday= c.getColumnIndex(KEY_BDAY);
int iMob= c.getColumnIndex(KEY_MOBNO);
int iMail= c.getColumnIndex(KEY_MAIL);
int iDate= c.getColumnIndex(KEY_DATE);
for (c.moveToFirst();c.isAfterLast();c.moveToNext()){
result= result +c.getString(iName) +" "+c.getString(iBday) +" "+
c.getString(iMob)+" "+c.getString(iMail)+" "+c.getString(iDate)+
"\n";
}
return result;
}

private static class DbHelper extends SQLiteOpenHelper{


public DbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + DATABASE_TABLE +" (" +
KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
KEY_NAME + " TEXT NOT NULL, " +
KEY_BDAY + " TEXT NOT NULL, " +
KEY_MOBNO + " TEXT NOT NULL, " +
KEY_MAIL + " TEXT NOT NULL, " +
KEY_DATE + " TEXT NOT NULL);"
);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE);
onCreate(db);
}
}
}

And here is My form.java in which Button executes following code in Onclicklistener.

C#
boolean ok=true;
                    try
                    {
                        String name=etname.getText().toString();
                        String bday=etbdate.getText().toString();
                        String mobno=etmobno.getText().toString();
                        String mail=etmailid.getText().toString();
                        String dater=date.toString();

                        DatabaseHelper entry=new DatabaseHelper(Form.this);
                        entry.open();
                        entry.createentry(name, bday, mobno, mail, dater);
                        entry.close();

                        Toast.makeText(getApplicationContext(), "Database Uploaded ", Toast.LENGTH_LONG).show();

                    }
                    catch(Exception ex)
                    {
                        ok=false;
                        catcherror(ex.toString());
                    }

AnswerRe: I have table not found in SQLite database table. Pin
Richard MacCutchan10-Aug-15 23:29
mveRichard MacCutchan10-Aug-15 23:29 
Questionhow to change the actionbar background color Pin
Member 118975669-Aug-15 21:16
Member 118975669-Aug-15 21:16 
SuggestionRe: how to change the actionbar background color Pin
Richard MacCutchan9-Aug-15 21:59
mveRichard MacCutchan9-Aug-15 21:59 
GeneralRe: how to change the actionbar background color Pin
Member 118975669-Aug-15 22:44
Member 118975669-Aug-15 22:44 
GeneralRe: how to change the actionbar background color Pin
Richard MacCutchan10-Aug-15 1:06
mveRichard MacCutchan10-Aug-15 1:06 
QuestionTable rows not scrolling Pin
pkfox24-Jul-15 20:53
professionalpkfox24-Jul-15 20:53 
AnswerRe: Table rows not scrolling Pin
Richard MacCutchan24-Jul-15 23:44
mveRichard MacCutchan24-Jul-15 23:44 
GeneralRe: Table rows not scrolling Pin
pkfox25-Jul-15 1:20
professionalpkfox25-Jul-15 1:20 
GeneralRe: Table rows not scrolling Pin
Richard MacCutchan25-Jul-15 2:31
mveRichard MacCutchan25-Jul-15 2:31 
GeneralRe: Table rows not scrolling Pin
Richard MacCutchan25-Jul-15 3:43
mveRichard MacCutchan25-Jul-15 3:43 
GeneralRe: Table rows not scrolling Pin
pkfox25-Jul-15 23:09
professionalpkfox25-Jul-15 23:09 
GeneralRe: Table rows not scrolling Pin
pkfox26-Jul-15 1:06
professionalpkfox26-Jul-15 1:06 
GeneralRe: Table rows not scrolling Pin
Richard MacCutchan26-Jul-15 1:23
mveRichard MacCutchan26-Jul-15 1:23 
AnswerRe: Table rows not scrolling Pin
Afzaal Ahmad Zeeshan25-Jul-15 1:53
professionalAfzaal Ahmad Zeeshan25-Jul-15 1:53 
GeneralRe: Table rows not scrolling Pin
pkfox25-Jul-15 23:11
professionalpkfox25-Jul-15 23:11 
AnswerRe: Table rows not scrolling Pin
Member 1190643213-Aug-15 0:43
Member 1190643213-Aug-15 0:43 
GeneralRe: Table rows not scrolling Pin
pkfox14-Aug-15 3:09
professionalpkfox14-Aug-15 3:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.