Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>EDIT:</strong> Replace your code with this and let me know what happen, (This works fine in my case..)</p> <p><strong>DbManager.java class:</strong></p> <pre><code>public class DbManager { private DatabaseHelper dataHelper; private SQLiteDatabase mDb; Context ctx; String DATABASE_PATH = "/data/data/com.demo/databases/"; static String DATABASE_NAME="AndroidDB"; private static final int DATABASE_VERSION = 1; DbManager(Context ctx) { this.ctx = ctx; dataHelper = new DatabaseHelper(ctx); } private static class DatabaseHelper extends SQLiteOpenHelper { Context myContext = null; public DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); this.myContext = context; // TODO Auto-generated constructor stub } @Override public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub Log.w("DBHelper", "Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data"); onCreate(db); } } public boolean checkDataBase() { String myPath = DATABASE_PATH + DATABASE_NAME; File f = new File(myPath); return f.exists(); } public void createDataBase() { openDB(); try { InputStream myInput = ctx.getAssets().open("AndroidDB.db"); OutputStream myOutput = new FileOutputStream(DATABASE_PATH + "AndroidDB"); byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer)) &gt; 0) { myOutput.write(buffer, 0, length); } if (mDb.isOpen()) mDb.close(); myOutput.flush(); myOutput.close(); myInput.close(); } catch (FileNotFoundException e) { throw new Error("file not found -- " + e.getMessage()); } catch (IOException e) { throw new Error("io exception " + e.getMessage()); } catch (Exception e) { throw new Error(" exception " + e.getMessage()); } } public DbManager openDB() throws SQLException { mDb = dataHelper.getWritableDatabase(); return this; } public String[] getSymbol() { Cursor cur; try { cur = mDb.rawQuery("select symbol,company_name from Scrip", null); } catch (SQLiteException e) { throw new Error(" *** ERROR in cursor *** " + e.getMessage()); } String[] b1 = new String[1326]; int x = 0; if (cur.moveToFirst()) { do { b1[x] = cur.getString(cur.getColumnIndex("symbol")); x++; } while (cur.moveToNext()); } cur.close(); return b1; } public void close() { try { mDb.close(); } catch (Exception e) { e.printStackTrace(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload