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 8032395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:22:16+00:00 2026-06-05T01:22:16+00:00

View Database XML file: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent android:layout_height=match_parent android:orientation=vertical android:background=@drawable/wood_bg >

  • 0

View Database XML file:

     <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" 
android:background="@drawable/wood_bg" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_marginBottom="10dp"
    android:layout_marginTop="10dp"
    android:text="Daily Fruit Log"
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:textStyle="bold"/>


<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <TableRow>

    <TextView
        android:layout_width="110dp"
        android:layout_height="fill_parent"
        android:text="Name of fruit" 
        android:layout_weight="1"
        android:textStyle="bold"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="No Of Fruit" 
        android:layout_weight="1"
        android:textStyle="bold"/>

     <TextView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="Total Calories" 
        android:layout_weight="1"
        android:textStyle="bold"/>

    </TableRow>
    </TableLayout>

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp">

    <TableRow>

    <TextView
    android:id="@+id/view"
    android:layout_width="110dp"
    android:layout_height="wrap_content"
    android:text="food"
    android:layout_weight="1" />

    <TextView
        android:id="@+id/view1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="1" 
        android:layout_weight="1"/>

     <TextView
         android:id="@+id/view2"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="20" 
        android:layout_weight="1"/>

    </TableRow>
    </TableLayout>

<Button
    android:id="@+id/bdelete"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Clear Log"
    android:layout_gravity="center"
    android:layout_marginTop="30dp" />

Java class of View Database page:

    public class FruitLog extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fruitlog);

            TextView tv = (TextView) findViewById(R.id.view);
            TextView tv1 = (TextView) findViewById(R.id.view1);
            TextView tv2 = (TextView) findViewById(R.id.view2);

            FruitDB info = new FruitDB(this);
            info.open();
            String data = info.getName();
            String data1 = info.getNum();
            String data2 = info.getCal();
            info.close();

            tv.setText(data);
            tv1.setText(data1);
            tv2.setText(data2);

            Button save = (Button) findViewById(R.id.bdelete);
            save.setTextColor(Color.BLUE);
            save.setOnClickListener(new View.OnClickListener(){

                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    FruitDB info = new FruitDB(FruitLog.this);
                    info.open();
                    info.deleteAll();
                    info.close();
                }

            });

}

I have edited the code, now I can delete all the data in my page, but the issue is that, I have to navigate back and enter this FruitLog page to see the changes (all rows deleted).
I want to see a immediate result when the user click ‘Clear Log’ Button without navigating back and front.

  • 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-05T01:22:18+00:00Added an answer on June 5, 2026 at 1:22 am

    This method in your db class:

    public boolean deleteAll() {        
        // Returns true if number of deleted rows is larger than 0;
        return mDb.delete(DATABASE_TABLE, null, 1) > 0;
    }
    

    In the onClickListener:

     public void onClick(View v) {
         FruitDB db = new FruitDB(YourClass.this);
         db.open();
             db.deleteAll();
         db.close();
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing lots of info from an XML file into a database. Everything
I have problem with proper charset encoding part of HTML view. XSL file in
how to insert database(DB2) tuples as XML elements in XML file using java? Is
I'm writing a database view to sum up a bunch of records where the
I have setup a database view. When users import the data from the view
I'm trying to query a database view that's not located on the same server
Im create this code to store page view in database, but i have problem
I want to make a view in a database via Java that has a
I have a view in my sql database and it's mapped in my dbml
how I can format my database-query in a list view with 2 signs after

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.