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

  • Home
  • SEARCH
  • 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 6339085
In Process

The Archive Base Latest Questions

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

I want to create an application where there is a button and each time

  • 0

I want to create an application where there is a button and each time this button is clicked that some random preset message is displayed on the screen. How should I go about storing these preset messages? Should I use an SQLite database or should I just create an array populated with the messages and retrieve the messages from there?

I am not looking for code. I just would like some hints, suggestions, or someone to point me to some documentation that might help me.

  • 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-24T19:34:45+00:00Added an answer on May 24, 2026 at 7:34 pm

    Oh, my first instinct was to start pumping out some code, but since you want to just look at some different options, here are the ones that I can think of

    Array: Hard code an Array of all your preset messages and then just make a Toast message with presetString[RandomNumber]. Nothing too fancy. Pretty much straight forward Java with an added toast message. (Information on toast messages and other options for displaying the message can be found here: http://developer.android.com/guide/topics/ui/notifiers/index.html)
    Advantage: simplicity. Its very easy to look at the code and see what your goal is. Disadvantage: It is cumbersome to deal with the array for really long lists and future updates can become burdensome. Also it would be difficult for you to use this in any other part of your program efficiently.

    strings.xml: http://developer.android.com/guide/topics/resources/string-resource.html Strings.xml is the more “Android Developer” ish approach in my opinion. You make one with all your possible messages and then load it into your application via the resource name. From there it is simply an array that you can perform the same operations you normally would.
    Advantage: since its in a centralized location with a resource identifier, any part of your program can use it. Has the same base functionality as an array
    Disadvantage: .apk files are signed, so because of that, your resources cannot be modified at runtime. The messages you put in here cannot be added to or changed

    Other storage types such as JSON are available. These would be similar to the strings.xml except for on more plus side; they are easily loaded from a remote server. Your application could make a remote call to request the full array and parse it from there http://damonsk.com/2010/01/jsonarray-httpclient-android/

    Finally, you COULD do a SQLLite database. Using them would require a great amount of overhead in there for such a simple seeming application. This would be preferred if you are looking for a persistent solution (one that will keep the data from use to use) AND is changeable. Say for example you would like to give the user the ability to add new entries, or maybe let the user change the messages or delete the ones that they don’t like, then this is the appropriate solution. The main concern is of course, is it really necessary? But if it is, then you can find more documentation on it here or here (shows you how to copy a SQLLIte db Be warned though that on Android 2.2 there is a bug that would keep you from adding files that are above 1megabyte in size as an asset, so if you REALLY had lots of messages to add, you would need to use this work around here

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

Sidebar

Related Questions

I want to create an application like this: http://collabedit.com/ What is the most efficient
I want to create an application for Android that will be able to scan
I want to create an application that doesn't use Portrait mode. I am not
I'm getting frustrated at this. I want to create an iPhone application to show
i want to create a small c# application. there is a text box and
I want to create application which would display spatial data on Map. I'm thinking
I want to create an application which will have a client and server components.
I want to create windows application in c# 2008. The problem is I don't
I want to create an application which main window has canvas (or something where
I have seen the Contacts in iPhone Simulator. I want to create an application

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.