Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need simple SQLite database example [duplicate]

Tags:

android

sqlite

Possible Duplicate:
sqlite example program in android

I need to open a database where I know the path/name, I need to read a known value, and write a value. I don't want to write 100 line "helper classes," I simply want to use the classes/functions that already exist. Can anybody provide a a simple example for this? It really shouldn't be more than a few lines of code.

1: Open database:

maybe this? openDatabase(String path, SQLiteDatabase.CursorFactory factory, int flags)

2: Execute SQL to display value (in a Toast perhaps)

3: Close database

Once I understand this basic functionality I will then worry about helper classes etc. Thanks in advance.

EDIT:

Fascinating that every single answer so far links to articles that do EXACTLY what I asked not to do. I just want a simple 3 line example of how to directly open a database and read from it.

like image 692
Jimmy D Avatar asked Dec 16 '22 08:12

Jimmy D


2 Answers

A very good SQLite tutorial.

like image 115
Vineet Shukla Avatar answered Jan 13 '23 16:01

Vineet Shukla


Run through the notepad tutorial

like image 30
f20k Avatar answered Jan 13 '23 16:01

f20k