logo
down
shadow

SQLiteException : No such table found whereas a table was created


SQLiteException : No such table found whereas a table was created

By : dacwen
Date : November 18 2020, 03:01 PM
wish helps you You are operating on two different database files, User_Details and User_Details.DB.
If you use SQLiteOpenHelper for managing your database, use it consistently. For example, replace
code :
db=Gps4Activity.this.openOrCreateDatabase("User_Details",MODE_PRIVATE,null);
db = new UserDatabase(this).getReadableDatabase();


Share : facebook icon twitter icon
No such table found- i created table using one application and i tried retrieve values from table using another applicat

No such table found- i created table using one application and i tried retrieve values from table using another applicat


By : dafortin
Date : March 29 2020, 07:55 AM
With these it helps sorry you can not access database from other application because its databases are stored in application storage under package directory.
If you want to access database from multiple application you need to create database on sdcard. Follow the stpes.
code :
public static final String  DATABASE_FILE_PATH = "/sdcard";
Environment.getExternalStorageDirectory()   
public class DatabaseHelper {
    private static final String TAG = "DatabaseHelper";
    public static final String DATABASE_FILE_PATH = Environment.getExternalStorageDirectory()+"/directorynameWhereYouWantTocreateDatabase";
    public static final String DATABASE_NAME = "mydb";
    public static final String TRACKS_TABLE = "tracks";
    public static final String TRACK_INFO_TABLE = "track_info";

    private static final String TRACKS_TABLE_CREATE = "create table " + TRACKS_TABLE
            + " (_id integer primary key autoincrement, title text not null, description text null, created_at date not null);";

    private static final String TRACK_INFO_TABLE_CREATE = "create table "
            + TRACK_INFO_TABLE
            + " (_id integer primary key autoincrement, track_id integer not null, latitude real not null, longitude real not null, altitude real not null, created_at date not null);";

    private SQLiteDatabase database;

    public DatabaseHelper() {
        try {
            database = SQLiteDatabase.openDatabase(DATABASE_FILE_PATH + File.separator + DATABASE_NAME, null, SQLiteDatabase.OPEN_READWRITE);
        } catch (SQLiteException ex) {
            Log.e(TAG, "error -- " + ex.getMessage(), ex);
            // error means tables does not exits
            createTables();
        } finally {
            close();
        }
    }

    private void createTables() {
        database.execSQL(TRACKS_TABLE_CREATE);
        database.execSQL(TRACK_INFO_TABLE_CREATE);
    }

    public synchronized void close() {
    if (database != null) {
        database.close();
    }

}

    public SQLiteDatabase getReadableDatabase() {
        database = SQLiteDatabase.openDatabase(DATABASE_FILE_PATH + File.separator + DATABASE_NAME, null, SQLiteDatabase.OPEN_READONLY);
        return database;
    }

    public SQLiteDatabase getWritableDatabase() {
        database = SQLiteDatabase.openDatabase(DATABASE_FILE_PATH + File.separator + DATABASE_NAME, null, SQLiteDatabase.OPEN_READWRITE);
        return database;
    }
}
Unable to start activity ,android.database.sqlite.SQLiteException: no such table, while compiling: SELECT * FROM table

Unable to start activity ,android.database.sqlite.SQLiteException: no such table, while compiling: SELECT * FROM table


By : user3001727
Date : March 29 2020, 07:55 AM
To fix this issue I see in you have two primary keys in your CREATE_TABLE_TRACK so just remove one of those to solve the problem. like this :
code :
//just removed one of ypur primary keys
String CREATE_TABLE_TRACK = "CREATE TABLE " + TABLE_TRACK + "("
                    + KEY_UIDTRACK + " INTEGER PRIMARY KEY," + KEY_DOCKETNO
                    + " INTEGER ," + KEY_DEALERNAME + " TEXT,"
                    + KEY_CUSTOMERNAME + " TEXT ," + KEY_PCS
                    + " INTEGER ," + KEY_DELIVERY_STATUS + " TEXT ,"
                    + KEY_REMARKS + " TEXT ," + KEY_CREATED_AT_TRACK + " TEXT"
                    + ")";
android.database.sqlite.SQLiteException: no such table: CLTABLE (code 1): , while compiling: INSERT INTO table

android.database.sqlite.SQLiteException: no such table: CLTABLE (code 1): , while compiling: INSERT INTO table


By : Siting Liu
Date : March 29 2020, 07:55 AM
may help you . Your table is not created so you got NPE.
You should add white space between Column Name and Column Type
code :
 private static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + "(" +
        COLUMN_UID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
        NAME + " VARCHAR(32) NOT NULL, " +
        NUMBER + " INTEGER, " +
        EMAIL + " VARCHAR(25) NOT NULL, " +
        JOBTYPE + " VARCHAR(20) NOT NULL, " +
        URI + " VARCHAR(50) NOT NULL, " +
        MSG + " VARCHAR(500) NOT NULL);";
Android onUpgrade SQLiteException: no such table when dropping table

Android onUpgrade SQLiteException: no such table when dropping table


By : Golden Strikez
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further This error can occur if there are foreign key constraints. Perhaps reversing the order of deletion.
Getting SQLiteException: Table not found

Getting SQLiteException: Table not found


By : anchr03
Date : March 29 2020, 07:55 AM
I wish this helpful for you The issue is nothing to do with the semi-colon.
The table not found is issued irrespective of the exception.
code :
public class g_dbHelper extends SQLiteOpenHelper implements BaseColumns {
    final static String DB_NAME="books.db";
    public g_dbHelper(Context context) {
        super(context,DB_NAME, null, 2);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {

        String create= "CREATE TABLE first ("+ BaseColumns._ID+" INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, PUBLISHER TEXT);";
        sqLiteDatabase.execSQL(create);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldversion, int newversion) {

    }
}
public class MainActivity extends AppCompatActivity {

    g_dbHelper helper;
    TextView txt;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        txt = (TextView) this.findViewById(R.id.textviewa);
        SO48472717();
    }

    private void SO48472717() {
        helper = new g_dbHelper((this));
        SQLiteDatabase sql = helper.getWritableDatabase();
        ContentValues values = new ContentValues();
        values.put("NAME", "Harry Potter");
        values.put("PUBLISHER", "Bloomberg Publications");
        long newRowId = sql.insert("first", null, values);
        String[] name = {"NAME"};
        SQLiteDatabase sql1 = helper.getReadableDatabase();
        Cursor cursor = sql1.query("first", name, null, null, null, null, null);
        //########################### Fix Here.
        if (cursor.moveToFirst()) {
            int id = cursor.getColumnIndex("NAME");
            txt.setText(cursor.getString(id));
        }
        //########################### End of Fix
        cursor.close();
    }
}
Related Posts Related Posts :
  • How to employ keyed-hash message authentication code (HMAC) with Android Keystore
  • Prevent inviting existing users or previously invited
  • How to overwrite windowSoftInputMode using edit-config tag in cordova
  • Difference between Loader and AsyncTask
  • In Firebase Android, retrieve the value of a child node and save it in a boolean variable
  • when i scroll the custom list in my android app then the favorite icon which is part of the custom adapter changes on it
  • adding room dependency gives manifest merge error
  • Visibility of RelativeLayout change on scrolling Gridview
  • Strange LiveData behavior vs ObservableField
  • Which layout is used for clash of clans home screen? We can scroll it horizontal as well as vertical. Please illuminate
  • RxJava: Know when observable is finished and return Boolean Observable to the caller
  • how to use savedInstanceState to save camera information when the orientation change occure
  • Style React-Native via Styles.xml
  • Keyboard won't show after calling InputMethodManager.showSoftInput
  • Compiling ffmpeg for Android on OSX
  • Button does not get clicked on the first attempt
  • AR Core performance, learning curve and comparison with other frameworks
  • Codename one : Attaching images to email message fails
  • Error: Unsupported type 'viewItem' in Android build
  • setLayoutParams on ConstraintLayout does not change size
  • How to profile the fetch time of the android gradle libraries
  • Kotlin setOnclickListener
  • Naming convention for methods returning RxJava's Completable
  • Conv3D not working
  • FFmpeg audio video merge command
  • Do you have to use gradle-experimental for JNI?
  • How to get key hashes for facebook for facebook app?
  • ZXing not calling onActivityResult, When scanning QR Code
  • Integration of Android Native module with existing Xamarin Native Project
  • Restore RecyclerView state after rotating
  • ViewModelProviders java.lang.RuntimeException trying to instantiate class which inherit AndroidViewModel
  • SKD19 vs SDK24 - Usage of API documented as @since 1.8+
  • filter option in list view fragment activity
  • Picture from camera not showing up in second activity
  • How to change imageview according to screen size
  • How to copy Android Studio project to remote Git (NOT GitHub) server
  • How to get React-Native to announce specific accessibility message via AccessibiliyManager?
  • Change colors of com.tech.freak.wizardpager.ui.StepPagerStrip
  • Android fullscreen activity shows ActionBar
  • Turn on the screen when timer calls onFinish()
  • Would like a bit of clarification with SQLite database's onUpgrade method
  • Use ObjectBox with Libgdx
  • How to make combine Gregorian and Hijri calendar in Android?
  • Try to read text file from sdcard in other language
  • "App not installed" message when installed apk
  • How to execute a designated test suite class in Firebase Test Lab
  • play music with background service
  • background not visible on LG G3
  • should every View have an id?
  • Realm object server sync on low connection.
  • Correct way to add more views to adapter
  • Getting error in android support library
  • Instant app zip uploading error
  • "No emulator installed" error in Android Studio even though Intel HAXM is up and running
  • AsyncTask without leaks
  • Using @Component.Builder with constructor params
  • No injector was found for fragment dagger 2.11
  • Android Volley Https SSL self signed and Google Maps API
  • Why does the onClickListener not work anymore in this example?
  • Why are my map marker ObjectAnimators getting canceled?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org