bhanu kaushik
bhanu kaushik

Reputation: 391

Storing and Displaying String from SQLite to MainActivity

I am new to android, just days old to SQLite Database.

In my application, I need to store 10 Strings in database, that I can display on the Main Activity, one string at a time and the string will change on the swipe.

I am following AndroidHive, but its not working for me.

I can do the swipe part myself, but can anybody suggest me the method or even some good links regarding storing strings into db? It will very helpful.

*Of all the tutorial that i am reading, they all are showing me how to allow user to put something into database where as what i want to already store the string into the database.

MainActivity:

String quotes1 = "My name is Bhanu";
String quotes2 = "My name is Rahul";
String quotes3 = "My name is not Bhanu";
String quotes4 = "My name is not Rahul";
String quotes5 = "My name is Anil";
String quotes6 = "My name is not Anil";
    int counter;
    Button choosenext;
    TextView display;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        counter=0;
        display = (TextView)findViewById(R.id.displaytext);
        choosenext = (Button)findViewById(R.id.next_choose);
        choosenext.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub

            }
        });

    }
}

Upvotes: 1

Views: 378

Answers (2)

Minas
Minas

Reputation: 1422

The best tutorial for beginners I know is Android SQLite database and content provider. It is very well explained. Follow the steps. Let me know if you have questions.

Upvotes: 2

Related Questions