Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8365303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:37:39+00:00 2026-06-09T12:37:39+00:00

I am new to android, using sqlite to insert data in database, and use

  • 0

I am new to android, using sqlite to insert data in database, and use these data on custom list view. The problem occurs when I edit the data with edit button in next activity show the row string but, in every row edit but show the data of 1st row string..
by image u can esily understand:
enter image description here

I want the row name in new activity page while i click on edit..
delete row when i press delete .. help me..

editlist java file

public class EditLIST extends Activity {


    private AndroidSQLite mySQLiteAdapter ;
final static String EXTRA_MESSAGE = "edit.list.message";
 public void onClick (View view) {


     Intent intent = new Intent (this,display.class);
     TextView textView=(TextView) findViewById(R.id.textView1);
     String message=textView.getText().toString();


     //data.putString("thetext",text);
     intent.putExtra(EXTRA_MESSAGE,message);
     startActivity(intent);
}
  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_list);
        ListView listContent = (ListView)findViewById(R.id.listView1);



        mySQLiteAdapter = new AndroidSQLite(this);
        mySQLiteAdapter.openToWrite();
      mySQLiteAdapter.deleteAll();

       mySQLiteAdapter.insert("umesh");
       mySQLiteAdapter.insert("kalpesh");
       mySQLiteAdapter.insert("manish");


        mySQLiteAdapter.close();

        mySQLiteAdapter = new AndroidSQLite(this);
        mySQLiteAdapter.openToRead();

        Cursor cursor = mySQLiteAdapter.queueAll();
        startManagingCursor(cursor);

        String[] from = new String[]{AndroidSQLite.KEY_FNAME};
        int[] to = new int[]{R.id.textView1};




        SimpleCursorAdapter cursorAdapter =
         new SimpleCursorAdapter(this, R.layout.button, cursor, from, to);


                  listContent.setAdapter(cursorAdapter);



    }


    }

AndroidSQLite.java file

package edit.list;

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

public class AndroidSQLite {

public static final String MYDATABASE_NAME = "abncd";
public static final String MYDATABASE_TABLE = "zxc";
public static final int MYDATABASE_VERSION = 1;
public static final String KEY_ID = "_id";
public static final String KEY_FNAME = "FNAME";



//create table MY_DATABASE (ID integer primary key, Content text not null);
private static final String SCRIPT_CREATE_DATABASE =
"create table " + MYDATABASE_TABLE + " ("
+ KEY_ID + " integer primary key autoincrement, "
+ KEY_FNAME + " text not null);";

private SQLiteHelper sqLiteHelper;
private SQLiteDatabase sqLiteDatabase;

private Context context;

public AndroidSQLite(Context c){
context = c;
}

public AndroidSQLite openToRead() throws android.database.SQLException {
sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null, MYDATABASE_VERSION);
sqLiteDatabase = sqLiteHelper.getReadableDatabase();
return this;
}

public AndroidSQLite openToWrite() throws android.database.SQLException {
sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null, MYDATABASE_VERSION);
sqLiteDatabase = sqLiteHelper.getWritableDatabase();
return this;
}

public void close(){
sqLiteHelper.close();
}

public long insert(String fname){

ContentValues contentValues = new ContentValues();

contentValues.put(KEY_FNAME, fname);

return sqLiteDatabase.insert(MYDATABASE_TABLE, null, contentValues);
}

public int deleteAll(){
return sqLiteDatabase.delete(MYDATABASE_TABLE, null, null);
}

public Cursor queueAll(){
String[] columns = new String[]{KEY_ID, KEY_FNAME};
Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns, 
  null, null, null, null, null);

return cursor;
}

public class SQLiteHelper extends SQLiteOpenHelper {

public SQLiteHelper(Context context, String name,
  CursorFactory factory, int version) {
 super(context, name, factory, version);
}

@Override
public void onCreate(SQLiteDatabase db) {
 // TODO Auto-generated method stub
 db.execSQL(SCRIPT_CREATE_DATABASE);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
 // TODO Auto-generated method stub

}

}

}

display.java

public class display extends Activity {
     public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.display);


                // Get the message from the intent
                Intent intent = getIntent();
                String message = intent.getStringExtra(EditLIST.EXTRA_MESSAGE);

                // Create the text view
                EditText editText = new EditText(this);
                editText.setTextSize(40);
                editText.setText(message);

                // Set the text view as the activity layout
                setContentView(editText);
                }
     public boolean onCreateOptionsMenu (Menu menu)
        {
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.activity_edit_list,menu);
            return true;
        }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:37:40+00:00Added an answer on June 9, 2026 at 12:37 pm

    I’m not sure If I understand you correctly. As I understood when you click edit you always get the data from the first item regardless of which item you actually clicked? In that case I think the problem is here :

    TextView textView=(TextView) findViewById(R.id.textView1);
    

    You’re searching for R.id.textView1 in the whole list and only the first item is being returned. You need to search only within the item clicked :

    TextView textView=(TextView) view.findViewById(R.id.textView1);
    

    Where view is the parameter to the onClick function.

    As I said I’m not sure if that was the question but it looks like a problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use SQLite in android development. When I insert a row using insert, I
While using sqlite database in android I am getting a weird problem. I am
I am new to using SQLite databases and android mobile development. I am trying
I am new to Android development and facing a problem while using AndEngine. I
I'm using Android's SQLite to create a database of levels, based on some files.
I'm having trouble querying my SQLite database using Android. I keep getting either an
I'm using the following code to display the values stored in Android sqlite database.
I'm using a background thread to read from a Sqlite database some GPS data...and
in my app i use Using an existing sqlite database and i need to
I've got an android app using a local sqlite database. private SQLiteDatabase mDb; when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.