简体   繁体   中英

Can anyone help how to implement Sqflite for the default flutter counter App?

I can make the db helper for sqflite and can also made crude operation with Sqflite. But I'm getting some problem with saving int. Which will be incremented. Suppose the default flutter counter App. Where i want to save the incremented int in database and then fatch the value. It will be a good learing for me if anyone have idea about it and share with me. Thanks

this is how sqllite table created

Future<Database> init() async {

Directory directory = await getApplicationDocumentsDirectory(); //returns a directory which stores permanent files
final path = join(directory.path,"pdf.db"); //create path to database

return await openDatabase( //open the database or create a database if there isn't any
    path,
    version: 1,
    onCreate: (Database db,int version) async{
     CREATE TABLE PDF(
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      email TEXT,
      name TEXT,
      password TEXT,
      confrimpassword TEXT,
      path TEXT)"""
      );
    });
  }

here id is the increment num it will auto generate incrementally

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM