-1

How can i using internal database for example (sqlite) for offline app in nativescript without using any plugin.

i'm searched every were how i can installed or used sqlite or other internal database for nativescript but i didn't have any answer.

Mo Shal
  • 1,587
  • 18
  • 25
  • 2
    The question shows little to no effort put into it. SQLite is not something you install, it's already embedded in the mobile platforms, you only have to make native API calls as the database is meant to be used. If you wish to not use a plugin (for whatever reason), then you will have to implement everything from scratch in JavaScript following the official documentation each platform (android/ios) has provided. – pkanev Mar 01 '17 at 12:00

1 Answers1

2

Just like you would do with any code that you need to access the native APIs

e.g. (JavaScript) Android example

var query = "select sqlite_version() AS sqlite_version";
var db = android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(":memory:", null);
var cursor = db.rawQuery(query, null);
var sqliteVersion = "";
if (cursor.moveToNext()) {
    sqliteVersion = cursor.getString(0);
    console.log(sqliteVersion);
}

The API references for SQLite in Android here and that said you can now follow a basic Android database tutorial and implement it step by step in your NativeScript application using JavaScript or TypeScript

Still, the plugin could provide all that wrapped in a ready-to-go functionality so unless you are lacking something it will be easier to use the nativescript-sqlite and avoid writing native code for Android and then for iOS.

Nick Iliev
  • 9,610
  • 3
  • 35
  • 89