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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:44:40+00:00 2026-05-24T09:44:40+00:00

My issue is this (Don’t let the paragraph intimidate you, my question is quite

  • 0

My issue is this (Don’t let the paragraph intimidate you, my question is quite simple I believe) :

In the MainActivity(A), I have a listView. When I click on an item in the listView, I go to a second activity(B). In activity B, I have a button that allows the user to take a picture. Now I save this picture under a filename. Since I want each listItem’s picture to be unique, I make the filename of the picture that item’s position. For example, if I click item#1 in the list, the corresponding picture’s name is "1". This all works very well except when I delete an item. Then, when I add another item at the same position, my code loads the existing picture for that item. e.g.- If I have a picture called '2' saved for an item2, it’s fine. when I delete this entry and add another item, which is the new item2, my code checks, “does the picture name '2' exist?”. If yes, then set this entry’s picture to that. Obviously this is a different entry and I don’t want this to happen. Possibly, I could delete the picture along with the item, but I have no clue how to do this.

I hope I explained my logic well. The only reason I am using the position is because that is the only unique thing about the item that I can find. By the way(not sure if this is relevant), I am passing the item position as an extra in the intent between Activity A and Activity B.

How can I solve this issue or use a workaround? Thanks!

EDIT 1:

Facepalm. By looking at comments, I realize that deleting it(as I stated earlier)^^, is the way to do this. Could someone tell me how to do this then?

This the code I am using to save the Image:

private void setImage() {
    if (loadPicture(getIntent().getStringExtra("position"), bitmap) != null) {
        // Toast.makeText(this, "not null", Toast.LENGTH_SHORT).show();
        imageView.setImageBitmap(loadPicture(
                getIntent().getStringExtra("position"), bitmap));
    }
}

private void savePicture(String filename, Bitmap b, Context ctx) {
    try {
        // ObjectOutputStream bos;
        FileOutputStream out;// = new FileOutputStream(filename);
        out = ctx.openFileOutput(filename, Context.MODE_WORLD_READABLE);
        // bos = new ObjectOutputStream(out);
        b.compress(Bitmap.CompressFormat.JPEG, 40, out);
        if (b.compress(Bitmap.CompressFormat.JPEG, 40, out) == true)
            // Toast.makeText(this, "returned true",
            // Toast.LENGTH_LONG).show();

            // bos.flush();
            // bos.close();
            out.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

Cheers.

  • 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-05-24T09:44:41+00:00Added an answer on May 24, 2026 at 9:44 am

    The way I solved this issue is by incrementing a counter every time I added the item, then saving this counter in the internal memory. This way, it was not based upon the position and would not get messed up when I deleted an item. I hope this continues to work as I make modifications to my application. Thanks to all for help.

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

Sidebar

Related Questions

This issue is giving me serious headaches, I don't have a clue what's going
I have this issue, but I don't know how to solve this: I have
I don't really know why I have this issue, I have looked over my
let's see how to explain this issue. I have 4 activities and 1 layout
I don't know what could be causing this issue, but for some reason, elements
This seems like it would be a common issue to be but I don't
I'm not sure if this is a simulator issue, but I don't remeber having
After reading this article I don't have a clear answer: http://palizine.plynt.com/issues/2010Oct/bypass-xss-filters/ Will browsers interpret
Jquery Each Json Values Issue This question is similar to above, but not the
I saw a patch for this issue but I don't know how to solve

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.