Database problem

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Database problem

Postby hakkatjai » Mon Jan 19, 2009 11:43 am

Hello Everyone,

FIrst of all i'm fairly new to Android and have been playing around for some days now. I have followed the Notepad tutorial from NotepadV1 to NotepadV3. After completing this tutorial i've been customizing the application with differents of api's, but i got stuck when i made a database connection in MyView class. Without the database connection it works perfectly. But then the count isn't dynamic. The application is actually still the same but instead of a list i wanted to show images.

the dbAdapter class is still the same as NotesDbAdapter. I just renamed it.

MyView
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class MyView extends View {
  3.  
  4.         private Drawable icon;
  5.  
  6.         private Cursor cursor;
  7.  
  8.        
  9.  
  10.         private DBAdapter dbAdapter;
  11.  
  12.        
  13.  
  14.  
  15.  
  16.         public MyView(Context context, AttributeSet attrs, int defStyle) {
  17.  
  18.                 super(context, attrs, defStyle);
  19.  
  20.                 loadTree(context);
  21.  
  22.         }
  23.  
  24.  
  25.  
  26.         public MyView(Context context, AttributeSet attrs) {
  27.  
  28.                 super(context, attrs);
  29.  
  30.                 loadTree(context);
  31.  
  32.         }
  33.  
  34.  
  35.  
  36.         public MyView(Context context) {
  37.  
  38.                 super(context);
  39.  
  40.                 loadTree(context);
  41.  
  42.         }      
  43.  
  44.        
  45.  
  46.         public void loadTree(Context context) {
  47.  
  48.                 icon = context.getResources().getDrawable(R.drawable.icon);
  49.  
  50.                
  51.  
  52.                 dbAdapter = new DBAdapter(context);
  53.  
  54.                 dbAdapter.open();
  55.  
  56.                
  57.  
  58.                 setFocusable(true);
  59.  
  60.         }
  61.  
  62.  
  63.  
  64.         @Override
  65.  
  66.         protected void onDraw(Canvas canvas) {
  67.  
  68.                 super.onDraw(canvas);
  69.  
  70.                
  71.  
  72.                 int count = dbAdapter.fetchAllNotes().getCount();
  73.  
  74.                
  75.  
  76.                 int i = 0;
  77.  
  78.                 while(i<count) {
  79.  
  80.                         icon.setBounds(15+i, 15+i, 15+i + 15+i, 15+i + 15+i);
  81.  
  82.                         icon.draw(canvas);
  83.  
  84.                         i = i++;
  85.  
  86.                 }
  87.  
  88.         }
  89.  
  90.  
  91.  
  92.         @Override
  93.  
  94.         public boolean onTouchEvent(MotionEvent event) {
  95.  
  96.                 return super.onTouchEvent(event);
  97.  
  98.         }
  99.  
  100. }
  101.  
  102.  
  103.  
  104.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


The error im getting is:
sqlexception no such table: notes

But i dont understand this, because i did:

dbAdapter = new DBAdapter(context);
dbAdapter.open();

it should be created and opened and if it does not exist it will be created, the flow is also good i debuged it in eclipse with some breakpoints.

If this can't be helped because of the structure the Notepad is, can someone give me a good practice of retrieving data from the databse from out a view class?
hakkatjai
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Jan 19, 2009 11:11 am

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: Google Feedfetcher and 4 guests