开发者

Generating automatic ID

开发者 https://www.devze.com 2023-03-01 12:58 出处:网络
I want to generate automat开发者_Go百科ic id of type ame100, ame101 and so on, so that as soon as I start my Android application, the next value of the series ame*** which is currently not in the data

I want to generate automat开发者_Go百科ic id of type ame100, ame101 and so on, so that as soon as I start my Android application, the next value of the series ame*** which is currently not in the database, should come automatically in edittext. So that on submitting the form I should have that value in database.


  1. Make your primary key autoincrement, so that db will generate the next value.

  2. Each time you need new id, just ask your databse for MAX(ID) from your table.

  3. Increment it and set to edittext!

Note: this solution works only if you have one place of inserting the values.

I would suggest not showing the number before inserting, but create it after, when you already have generated id of the object.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号