1. Download our Official Android App: Forums for Android!

Need help in app

Discussion in 'Android Apps & Games' started by reshmavt, Sep 8, 2011.

  1. reshmavt

    reshmavt Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Sep 8, 2011

    Sep 8, 2011
    1
    0
    5
    San Diego
    Hi,

    I am new to android apps development. I tried to submit my app in amazon but facing some issues. Will really appreciate if somebody helps me to some this issue.

    Thanks


    The error log from amazon team,

    08-11 10:41:29.136 W/dalvikvm(3898): VFY: rejecting call to Lcom/amazon/android/Kiwi;.onActivityResult (Landroid/app/Activity;IILandroid/content/Intent;)Z
    08-11 10:41:29.136 W/dalvikvm(3898): VFY: rejecting opcode 0x71 at 0x0000
    08-11 10:41:29.136 W/dalvikvm(3898): VFY: rejected Lcom/android/mygroceries/DataBaseHelper;.onActivityResult (IILandroid/content/Intent;)V
    08-11 10:41:29.136 W/dalvikvm(3898): Verifier rejected class Lcom/android/mygroceries/DataBaseHelper;
    08-11 10:41:29.136 D/AndroidRuntime(3898): Shutting down VM
    08-11 10:41:29.136 W/dalvikvm(3898): threadid=1: thread exiting with uncaught exception (group=0x400259f8)
    08-11 10:41:29.136 E/AndroidRuntime(3898): FATAL EXCEPTION: main
    08-11 10:41:29.136 E/AndroidRuntime(3898): java.lang.VerifyError: com.android.mygroceries.DataBaseHelper
    08-11 10:41:29.136 E/AndroidRuntime(3898): at com.android.mygroceries.mainmenu.onCreatemainmenu(mainmenu.java)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at com.android.mygroceries.mainmenu.onCreate(mainmenu.java)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1069)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2803)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at android.app.ActivityThread.access$2300(ActivityThread.java:135)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2136)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at android.os.Handler.dispatchMessage(Handler.java:99)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at android.os.Looper.loop(Looper.java:144)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at android.app.ActivityThread.main(ActivityThread.java:4937)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at java.lang.reflect.Method.invokeNative(Native Method)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at java.lang.reflect.Method.invoke(Method.java:521)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    08-11 10:41:29.136 E/AndroidRuntime(3898): at dalvik.system.NativeStart.main(Native Method)
    08-11 10:41:29.146 W/ActivityManager(97): Force finishing activity com.android.mygroceries/.mainmenu



    my database activity file:


    public class DataBaseHelper extends SQLiteOpenHelper {

    private static String DB_PATH = "/data/data/com.android.mydatabase/databases/";
    private static String DB_NAME = "knowLanguage.db";

    private SQLiteDatabase db;
    private final Context myContext;


    /**
    * Constructor
    * Takes and keeps a reference of the passed context in order to access to the application assets and resources.
    * @param context
    */
    public DataBaseHelper(Context context) {

    super(context, DB_NAME, null, 1);
    this.myContext = context;
    }

    public void createDataBase() throws IOException{

    try {
    if(!this.checkDataBase()){
    try {
    this.getWritableDatabase();
    /*Log.i("DATABASE:", "WRITABLE");*/
    } catch(SQLiteException ex) {
    this.getReadableDatabase();
    /*Log.i("DATABASE:", "READABLE");*/
    }
    this.close();
    try {
    this.copyDataBase(myContext);
    /*Log.i("DATABASE:", "COPY");*/
    } catch (IOException e) {
    Log.e("Database Error:", "Error copying database");
    }
    }
    this.close();
    } catch(SQLException eSQL){
    Log.e("log_tag","Can not open database");
    }
    }

    private boolean checkDataBase(){

    File dbFile = new File(DB_PATH+DB_NAME);
    return dbFile.exists();
    }


    public SQLiteDatabase copyDataBase(Context context) throws IOException,SQLiteException{

    if (db != null && db.isOpen()) {
    db.close();
    }

    File fileTest = context.getFileStreamPath(DB_NAME);
    boolean exists = fileTest.exists();

    if(exists==false)
    {
    InputStream myInput = context.getAssets().open(DB_NAME, Context.MODE_PRIVATE);
    OutputStream myOutput = new FileOutputStream(DB_PATH + DB_NAME);
    byte[] buffer = new byte[1024];
    int length;

    while ((length = myInput.read(buffer)) > 0) {
    myOutput.write(buffer, 0, length);
    }

    myOutput.flush();
    myOutput.close();
    myInput.close();
    }

    return db = SQLiteDatabase.openDatabase(DB_PATH + DB_NAME, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS);
    }

    public void openDataBase() throws SQLException{
    String myPath = DB_PATH + DB_NAME;
    db = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
    }

    @Override
    public synchronized void close() {
    if(db != null && db.isOpen())
    db.close();
    super.close();
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

    }
     

    Advertisement

Share This Page

Loading...