Edit and Delete Operation Needed.

Put your problem here if it does not fit any of the other categories.

Edit and Delete Operation Needed.

Postby joshikirti007 » Wed Feb 22, 2012 6:29 pm

Hi !!!

i attach one small project here, in which i try to develop code for EDIT and DELETE operation, with database,
but its not done propare, i attach my small project here with attachment , please help me in coding to edit and delete record from database, for that i create design xml files, in which i try to edit and delete record featching by email address, when user enter email address, that match same record in database and fill all fields with data that related to particular email address, that entered by user, on base of email i want to edit and delete record from database.

So, please help me to do these tinny tasks, (i'm new to android field.)

Help me please...... :)
Attachments
PAFM-j.rar
my small insert, edit, delete project with android (java), need help in edit and delete operations, design structures are ready. please help me. please check attachment file.
(1.48 MiB) Downloaded 27 times
joshikirti007
Junior Developer
Junior Developer
 
Posts: 11
Joined: Fri Feb 10, 2012 6:46 am

Top

Re: Edit and Delete Operation Needed.

Postby Phyll » Sun Feb 26, 2012 12:43 pm

Hi joshikirti,

I was wondering if you got any "help" yet?

I think you need to make the create line for your DB like this:

static String table_register = "CREATE TABLE register(user_id integer primary key autoincrement," +
"user_name text, password text, email text, address text, state text)";

Then you will actually make a DB for this form.

Beyond that, I'm not sure what your question is.

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: Edit and Delete Operation Needed.

Postby nuetronprotron » Tue Feb 28, 2012 12:46 pm

hi jyoshikirti,
you have to design your app in a better manner than what u have sent.Try to divide your work into small parts and name them according to the work that the method will be doing for example like this

please try to look into queries and their correct annoations i.e. every query should end with a semi-colon(this what missing in your query codings)
this should your database class:

public class DictionaryOpenHelper extends SQLiteOpenHelper {

private static final int DATABASE_VERSION = 2;
private static final String DICTIONARY_TABLE_NAME = "dictionary";
private static final String DICTIONARY_TABLE_CREATE =
"CREATE TABLE " + DICTIONARY_TABLE_NAME + " (" +
KEY_WORD + " TEXT, " +
KEY_DEFINITION + " TEXT);"; //try to observe here that you are missing in your query codings i.e. ";"

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

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DICTIONARY_TABLE_CREATE);
}

//methods to execute query
public void Execute_query(String query){
db.execSQL(query);
}
public Cursor Select_query(String query,String[] selectionArgs){
return db.rawQuery(query, selectionArgs);
}
//close method

}

onething you should take care is how ur app should work with these operations.
I mean you should first design your workflow then it will be easy for u to code properly.
for example your edit operation is actually an "UPDATE" operation in database,so first u should check for presence of the data u are requesting and after then only u should
execute update operation on that data.this case does apply even to the delete operation.If u try to do these operations without checking exceptions will be thrown.


this should be like your main class

public class Main extends Activity{
private DictionaryOpenHelper db;

public onCreate(){
super.onCreate();
setContentView(R.id.main);
init();
//here components have to be initialised

}

private void init(){
//creating the database here
db = new DictionaryOpenHelper(this);
}

//Action-listeners like onClick events here
private View.OnClick clickEventListener = new View.onClickEventListener(

public void onClick(View v){

switch(v.getId)
case R.id.btnCreateUser:
//first check for the elements to be not empty because these will go into the databases
//create your insert operation
databaseOperation(INSERT,insertQuery);
break;
case R.id.Cancel:

break;
}

);

databaseOperations(int queryMode,String query){
switch(queryMode)
case INSERT:
db.execute_Query(query);
break;
case EDIT:
//your edit is actually the update operation in sqlite see its query
db.execute_query(query);
break;
case DELETE:
d//here delete operation query


}

}
nuetronprotron
Developer
Developer
 
Posts: 37
Joined: Tue Jan 10, 2012 10:22 am

Re: Edit and Delete Operation Needed.

Postby joshikirti007 » Tue Feb 28, 2012 3:42 pm

Thanks - Phyll and nuetronprotron, for your reply and suggestions,

If you've any small inventory application like "inventory droid" or any other simple insert, update, delete application with android then please mail me, i want it , just for study purpose, and its very urgent, so, please make reply fast. my mail address : info@kmwebsoft.in

Thanks in advance.,, please help me, god helps u.
joshikirti007
Junior Developer
Junior Developer
 
Posts: 11
Joined: Fri Feb 10, 2012 6:46 am

Re: Edit and Delete Operation Needed.

Postby joshikirti007 » Tue Feb 28, 2012 4:03 pm

@ nuetronprotron -

thanks for your help, i'm littel bit confuzzz about update operation, there is in my small project - i design one xml file that collect email address for update operation from user, who register, now i want to check that email address is in database or not , so, how to check that and if email is in database then base of that email id, i wanna all other related records like user name, password, address, state, etc..... how to code for that, that fetch record and after fetching record i want to show all in text box that i design another "UPDATE Detail" xml file.

can you help me littel bit, i try for that you told me, but its not done still, can you develop small example for me, that have two xml design file one have email and find button, and another have some other text boxes that show data from database after checking email address is there in database with update button, when data fill with records and user will click update button that time records are update in database.

help me please.
joshikirti007
Junior Developer
Junior Developer
 
Posts: 11
Joined: Fri Feb 10, 2012 6:46 am

Re: Edit and Delete Operation Needed.

Postby Phyll » Wed Feb 29, 2012 6:08 am

Hi joshikirti007,

This probably isn't exactly what you want to do but it should have everything you need in it.

Hope this helps.

Phyll
Attachments
SqlTest.zip
SQLite example
(72.03 KiB) Downloaded 21 times
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Top

Re: Edit and Delete Operation Needed.

Postby joshikirti007 » Wed Feb 29, 2012 10:30 am

Thanks Phyll for help,

there is one little problem, when i try to run SQLite example, that time 2 errors occurs,

these are ::

[2012-02-29 14:31:47 - SqlTest] Could not find SqlTest.apk!
[2012-02-29 14:34:19 - SqlTest] Project has no default.properties file! Edit the project properties to set one.

how to fix these errors ???
joshikirti007
Junior Developer
Junior Developer
 
Posts: 11
Joined: Fri Feb 10, 2012 6:46 am

Re: Edit and Delete Operation Needed.

Postby Phyll » Wed Feb 29, 2012 12:56 pm

Hi joshikirti007,

The proper way to load that into Eclipse is to use File/Import/Existing projects into workspace. Just browse to where it has been unzipped and Eclipse will do the rest.

I zipped the entire project and its dependent files are relative to my setup. You need to make it relative to your setup if you are going to try to run it. Import will do that for you and you should have a usable project afterwards.

Failing this, just copy/paste the source into a new project and fixup anything that needs it.

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 12 guests