0

Hello I have a program which creates a random string every 3 seconds After generating string I want to save it and show all strings in a listview Thanks for any help

3 Answers 3

1

If you want to save it permanently you should read about SQLiteDatabases in Android.

If it can be deleted after you app closes you can just store it in a member variable. See here for some hints: How to fill a ListView with a string-array?

Sign up to request clarification or add additional context in comments.

Comments

0

create ArrayList

        ArrayList<String> itemList = new ArrayList<>(Arrays.asList(subject)); 

then Add the String to ArrayList

        itemList.add("your String");

use the below code to show them as list

    adapter = new ArrayAdapter<>(this, simple_list_item_1, itemList);
    ListView listV = (ListView) findViewById(R.id.list1);
    listV.setAdapter(adapter);

Comments

0

You got planty of storage options when working with Android.

Android provides several options for you to save persistent application data. The solution you choose depends on your specific needs, such as whether the data should be private to your application or accessible to other applications (and the user) and how much space your data requires.

Your data storage options are the following:

Shared Preferences Store private primitive data in key-value pairs. Internal Storage Store private data on the device memory. External Storage Store public data on the shared external storage. SQLite Databases Store structured data in a private database. Network Connection Store data on the web with your own network server.

Read more about it here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.