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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:39:35+00:00 2026-06-16T14:39:35+00:00

As a an inexperienced Android programmer I need some help. I’m designing this app

  • 0

As a an inexperienced Android programmer I need some help. I’m designing this app for a church that needs an Activity that can record prayer requests (similar to making a to-do list). At this point I can type items into a list, but they don’t seem to save and come back after closing using the Shared Preferences excerpt from below, also looking around this site it looks like I can do this without a physical button to press to save.

SharedPreferences prayerRequests = getPreferences(Activity.MODE_PRIVATE);

ListView myListViewa = (ListView)findViewById(R.id.myListView);

SharedPreferences.Editor editor = prayerRequests.edit();

editor.putString("prayers", myListViewa.toString());

editor.apply();

The entire class is here:

   package com.direction.investor.prayerjournal;

   import java.util.ArrayList;



   import android.annotation.TargetApi;
   import android.app.Activity;
   import android.os.Build;
   import android.os.Bundle;
   import android.view.KeyEvent;
   import android.view.View;
   import android.widget.ArrayAdapter;
   import android.widget.EditText;
   import android.widget.ListView;
   import android.widget.TextView;
   import android.content.SharedPreferences;
   import android.content.SharedPreferences.Editor;



 public class prayerRequests extends Activity {

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public void onCreate(Bundle savedInstanceState) 
{ super.onCreate(savedInstanceState);
setContentView(R.layout.prayerrequest);

ListView myListView = (ListView)findViewById(R.id.myListView);
final EditText myEditText = (EditText)findViewById(R.id.myEditText);

final ArrayList<String> prayers = new ArrayList<String> ();

final ArrayAdapter<String> aa;

aa = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, prayers);

myListView.setAdapter(aa);



SharedPreferences prayerRequests = getPreferences(Activity.MODE_PRIVATE);

ListView myListViewa = (ListView)findViewById(R.id.myListView);

SharedPreferences.Editor editor = prayerRequests.edit();

editor.putString("prayers", myListViewa.toString());

editor.apply();






myEditText.setOnKeyListener(new View.OnKeyListener() {
    public boolean onKey(View v, int keyCode, KeyEvent event) {
        if (event.getAction() == KeyEvent.ACTION_DOWN)
            if ((keyCode == KeyEvent.KEYCODE_DPAD_CENTER) ||
                    (keyCode == KeyEvent.KEYCODE_ENTER)) {

                prayers.add(0, myEditText.getText().toString());
                aa.notifyDataSetChanged();
                myEditText.setText("");
                return true;

            }
        return false;
    }
});


}


}
  • 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-16T14:39:36+00:00Added an answer on June 16, 2026 at 2:39 pm

    I would suggest to use database instead of sharedpreferences

    seee http://developer.android.com/guide/topics/data/data-storage.html#db

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

Sidebar

Related Questions

Inexperienced with c++ structures: I need a structure that fills the following: Can hold
I'm am pretty inexperienced with c++, but could use some help. I'm trying to
An inexperienced PHP question: I've got a PHP script file that I need to
I am rather inexperienced C++ programmer, so this question is probably rather basic. I
I am very inexperienced with SQL. I have a table that looks like this:
I'm a pretty inexperienced programmer (can make tk apps, text processing, sort of understand
I am pretty inexperienced with C++ however I need to use it for this
An inexperienced question: I need to store about 10 unknown-length text fields per record
I am designing the user interface of a web application but I am inexperienced
I need a round corner on my website. I'm fairly inexperienced with jQuery and

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.