Java 限制免费版本的数据库条目

Java 限制免费版本的数据库条目,java,android,Java,Android,我想提供我的应用程序的免费版本。限制是,一旦您将15条注释保存到数据库中,您将被限制为每月添加5条注释。每次您达到限制,每次您尝试在达到限制后制作新便笺时,我都会提示用户通过应用内购买解锁应用。在初始限制达到30天后,或者如果更容易的话,在月初,他们可以添加5个注释,在他们全部使用之前,我不会打扰他们。限制不会改变 有人对解决这个问题的最佳方法有什么想法吗?我强烈建议您使用web通信来实现这一点,即使您的应用程序不使用internet。如果您真的希望能够相信用户不会篡改参数来弥补额外的免费使用,

我想提供我的应用程序的免费版本。限制是,一旦您将15条注释保存到数据库中,您将被限制为每月添加5条注释。每次您达到限制,每次您尝试在达到限制后制作新便笺时,我都会提示用户通过应用内购买解锁应用。在初始限制达到30天后,或者如果更容易的话,在月初,他们可以添加5个注释,在他们全部使用之前,我不会打扰他们。限制不会改变


有人对解决这个问题的最佳方法有什么想法吗?

我强烈建议您使用web通信来实现这一点,即使您的应用程序不使用internet。如果您真的希望能够相信用户不会篡改参数来弥补额外的免费使用,那么您应该在自己的服务器上进行验证,而不是在他们的设备上

无论何时创建便笺,都应向服务器发送一条带有用户标识符的消息。然后,您可以跟踪注释(即使您没有存储注释的内容),并在需要阻止创建注释时发送消息


通过这种方式,如果必须,您也可以在不更改应用程序的情况下更改阈值。

我建议您查看一下。 实现该模式的解决方案包括:

  • 用于向数据库添加注释的类。让我们调用方法addNote(Note newNote)
课堂笔记管理{ 公共布尔addNote(Note newNote){ //向数据库添加注释并返回注释是否成功 } }
  • 包装上一个类并重写该方法的类:
类TrialNotesManagement扩展了NotesManagement{ 私人票据管理; 公共交通管理{ notesManagement=新的notesManagement(); } @凌驾 公共布尔addNote(Note newNote){ 如果(允许添加()){ returnnotesmanagement.add(newNote); }否则{ 返回false; } } 私有布尔值被允许添加(){ //进行检查——建议:在“数据库”中有一个计数器,该计数器在每月的第一个日期重置 } }
  • 处理请求的类应如下所示:
类AppController{ 笔记管理笔记管理; 公共应用程序控制器(){ if(isTrial()){ notesManagement=new-TrialNotesManagement(); }否则{ notesManagement=新的notesManagement(); } } 公共布尔addNote(Note newNote){ notesManagement.addNote(newNote); } }
不幸的是,我不能走这条路。我不能要求上网,而且我没有服务器。另一个应用程序的好主意。 class NotesManagement { public boolean addNote(Note newNote) { //Add Note to database and return whether it was successfull or not } } class TrialNotesManagement extends NotesManagement { private NotesManagement notesManagement; public TrialNotesManagement() { notesManagement = new NotesManagement(); } @Override public boolean addNote(Note newNote) { if (isAllowedToAdd()) { return notesManagement.add(newNote); } else { return false; } } private boolean isAllowedToAdd() { //Do the check--Suggestion: in the "database" have a counter that it's reseted each 1st daty of the month } } class AppController { NotesManagement notesManagement; public AppController() { if (isTrial()) { notesManagement = new TrialNotesManagement(); } else { notesManagement = new NotesManagement(); } } public boolean addNote(Note newNote) { notesManagement.addNote(newNote); } }